diff --git a/cmd/kubelet/app/server.go b/cmd/kubelet/app/server.go index 7d034c65fca..3c089f51457 100644 --- a/cmd/kubelet/app/server.go +++ b/cmd/kubelet/app/server.go @@ -100,6 +100,7 @@ type KubeletServer struct { NodeStatusUpdateFrequency time.Duration ResourceContainer string CgroupRoot string + ContainerRuntime string // Flags intended for testing @@ -153,6 +154,7 @@ func NewKubeletServer() *KubeletServer { NodeStatusUpdateFrequency: 10 * time.Second, ResourceContainer: "/kubelet", CgroupRoot: "", + ContainerRuntime: "docker", } } @@ -205,6 +207,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&s.CloudConfigFile, "cloud-config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.") fs.StringVar(&s.ResourceContainer, "resource-container", s.ResourceContainer, "Absolute name of the resource-only container to create and run the Kubelet in (Default: /kubelet).") fs.StringVar(&s.CgroupRoot, "cgroup_root", s.CgroupRoot, "Optional root cgroup to use for pods. This is handled by the container runtime on a best effort basis. Default: '', which means use the container runtime default.") + fs.StringVar(&s.ContainerRuntime, "container_runtime", s.ContainerRuntime, "The container runtime to use. Possible values: 'docker'. Default: 'docker'.") // Flags intended for testing, not recommended used in production environments. fs.BoolVar(&s.ReallyCrashForTesting, "really-crash-for-testing", s.ReallyCrashForTesting, "If true, when panics occur crash. Intended for testing.") @@ -305,6 +308,7 @@ func (s *KubeletServer) Run(_ []string) error { NodeStatusUpdateFrequency: s.NodeStatusUpdateFrequency, ResourceContainer: s.ResourceContainer, CgroupRoot: s.CgroupRoot, + ContainerRuntime: s.ContainerRuntime, } RunKubelet(&kcfg, nil) @@ -414,6 +418,7 @@ func SimpleKubelet(client *client.Client, ResourceContainer: "/kubelet", OSInterface: osInterface, CgroupRoot: "", + ContainerRuntime: "docker", } return &kcfg } @@ -542,6 +547,7 @@ type KubeletConfig struct { ResourceContainer string OSInterface kubecontainer.OSInterface CgroupRoot string + ContainerRuntime string } func createAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.PodConfig, err error) { @@ -587,7 +593,8 @@ func createAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod kc.NodeStatusUpdateFrequency, kc.ResourceContainer, kc.OSInterface, - kc.CgroupRoot) + kc.CgroupRoot, + kc.ContainerRuntime) if err != nil { return nil, nil, err diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 6fedec68d0d..814cf5e62cb 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -120,7 +120,8 @@ func NewMainKubelet( nodeStatusUpdateFrequency time.Duration, resourceContainer string, osInterface kubecontainer.OSInterface, - cgroupRoot string) (*Kubelet, error) { + cgroupRoot string, + containerRuntime string) (*Kubelet, error) { if rootDirectory == "" { return nil, fmt.Errorf("invalid root directory %q", rootDirectory) } @@ -240,6 +241,15 @@ func NewMainKubelet( } else { klet.networkPlugin = plug } + + // TODO(vmarmol,yjhong): Use container runtime. + // Initialize the runtime. + switch containerRuntime { + case "docker": + // Only supported one for now, continue. + default: + return nil, fmt.Errorf("unsupported container runtime %q specified", containerRuntime) + } containerManager := dockertools.NewDockerManager( dockerClient, recorder,