Skip to content

Commit

Permalink
Merge pull request #7652 from vmarmol/runtime-switch
Browse files Browse the repository at this point in the history
Kubelet: Add container runtime option.
  • Loading branch information
yujuhong committed May 1, 2015
2 parents e3fc039 + d9d61c3 commit ae1b24f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion cmd/kubelet/app/server.go
Expand Up @@ -100,6 +100,7 @@ type KubeletServer struct {
NodeStatusUpdateFrequency time.Duration
ResourceContainer string
CgroupRoot string
ContainerRuntime string

// Flags intended for testing

Expand Down Expand Up @@ -153,6 +154,7 @@ func NewKubeletServer() *KubeletServer {
NodeStatusUpdateFrequency: 10 * time.Second,
ResourceContainer: "/kubelet",
CgroupRoot: "",
ContainerRuntime: "docker",
}
}

Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -414,6 +418,7 @@ func SimpleKubelet(client *client.Client,
ResourceContainer: "/kubelet",
OSInterface: osInterface,
CgroupRoot: "",
ContainerRuntime: "docker",
}
return &kcfg
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion pkg/kubelet/kubelet.go
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ae1b24f

Please sign in to comment.