mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Merge pull request #7652 from vmarmol/runtime-switch
Kubelet: Add container runtime option.
This commit is contained in:
commit
ae1b24f07f
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user