Merge pull request #7652 from vmarmol/runtime-switch

Kubelet: Add container runtime option.
This commit is contained in:
Yu-Ju Hong 2015-05-01 14:50:30 -07:00
commit ae1b24f07f
2 changed files with 19 additions and 2 deletions

View File

@ -100,6 +100,7 @@ type KubeletServer struct {
NodeStatusUpdateFrequency time.Duration NodeStatusUpdateFrequency time.Duration
ResourceContainer string ResourceContainer string
CgroupRoot string CgroupRoot string
ContainerRuntime string
// Flags intended for testing // Flags intended for testing
@ -153,6 +154,7 @@ func NewKubeletServer() *KubeletServer {
NodeStatusUpdateFrequency: 10 * time.Second, NodeStatusUpdateFrequency: 10 * time.Second,
ResourceContainer: "/kubelet", ResourceContainer: "/kubelet",
CgroupRoot: "", 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.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.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.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. // 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.") 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, NodeStatusUpdateFrequency: s.NodeStatusUpdateFrequency,
ResourceContainer: s.ResourceContainer, ResourceContainer: s.ResourceContainer,
CgroupRoot: s.CgroupRoot, CgroupRoot: s.CgroupRoot,
ContainerRuntime: s.ContainerRuntime,
} }
RunKubelet(&kcfg, nil) RunKubelet(&kcfg, nil)
@ -414,6 +418,7 @@ func SimpleKubelet(client *client.Client,
ResourceContainer: "/kubelet", ResourceContainer: "/kubelet",
OSInterface: osInterface, OSInterface: osInterface,
CgroupRoot: "", CgroupRoot: "",
ContainerRuntime: "docker",
} }
return &kcfg return &kcfg
} }
@ -542,6 +547,7 @@ type KubeletConfig struct {
ResourceContainer string ResourceContainer string
OSInterface kubecontainer.OSInterface OSInterface kubecontainer.OSInterface
CgroupRoot string CgroupRoot string
ContainerRuntime string
} }
func createAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.PodConfig, err error) { 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.NodeStatusUpdateFrequency,
kc.ResourceContainer, kc.ResourceContainer,
kc.OSInterface, kc.OSInterface,
kc.CgroupRoot) kc.CgroupRoot,
kc.ContainerRuntime)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err

View File

@ -120,7 +120,8 @@ func NewMainKubelet(
nodeStatusUpdateFrequency time.Duration, nodeStatusUpdateFrequency time.Duration,
resourceContainer string, resourceContainer string,
osInterface kubecontainer.OSInterface, osInterface kubecontainer.OSInterface,
cgroupRoot string) (*Kubelet, error) { cgroupRoot string,
containerRuntime string) (*Kubelet, error) {
if rootDirectory == "" { if rootDirectory == "" {
return nil, fmt.Errorf("invalid root directory %q", rootDirectory) return nil, fmt.Errorf("invalid root directory %q", rootDirectory)
} }
@ -240,6 +241,15 @@ func NewMainKubelet(
} else { } else {
klet.networkPlugin = plug 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( containerManager := dockertools.NewDockerManager(
dockerClient, dockerClient,
recorder, recorder,