Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to force docker to use systemd as cgroup manager #7815

Merged
merged 20 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/minikube/cruntime/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,8 @@ func addRepoTagToImageName(imgName string) string {
} // else it already has repo name dont add anything
return imgName
}

// TODO: Enable for containerd
func (r *Containerd) ForceSystemdCgroupManager() error {
return nil
}
5 changes: 5 additions & 0 deletions pkg/minikube/cruntime/crio.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,8 @@ func (r *CRIO) Preload(cfg config.KubernetesConfig) error {
}
return fmt.Errorf("not yet implemented for %s", r.Name())
}

// ForceSystemdCgroupManager does nothing since CRIO already uses systemd
func (r *CRIO) ForceSystemdCgroupManager() error {
return nil
}
2 changes: 2 additions & 0 deletions pkg/minikube/cruntime/cruntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ type Manager interface {
SystemLogCmd(int) string
// Preload preloads the container runtime with k8s images
Preload(config.KubernetesConfig) error
// ForceSystemdCgroupManager forces the runtime to use systemd as cgroup manager
ForceSystemdCgroupManager() error
}

// Config is runtime configuration
Expand Down
19 changes: 19 additions & 0 deletions pkg/minikube/cruntime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,25 @@ func dockerImagesPreloaded(runner command.Runner, images []string) bool {
return true
}

// ForceSystemdCgroupManager forces docker to use systemd as cgroup manager, as recommended in k8s docs:
// https://kubernetes.io/docs/setup/production-environment/container-runtimes/#docker
func (r *Docker) ForceSystemdCgroupManager() error {
priyawadhwa marked this conversation as resolved.
Show resolved Hide resolved
daemonConfig := `{
"exec-opts": ["native.cgroupdriver=systemd"],
priyawadhwa marked this conversation as resolved.
Show resolved Hide resolved
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
`
ma := assets.NewMemoryAsset([]byte(daemonConfig), "/etc/docker", "daemon.json", "0644")
if err := r.Runner.Copy(ma); err != nil {
return errors.Wrap(err, "copying daemon config")
}
return r.Restart()
}

func dockerBoundToContainerd(runner command.Runner) bool {
// NOTE: assumes systemd
rr, err := runner.RunCmd(exec.Command("sudo", "systemctl", "cat", "docker.service"))
Expand Down
7 changes: 7 additions & 0 deletions pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {

// setup kubeadm (must come after setupKubeconfig)
bs = setupKubeAdm(starter.MachineAPI, *starter.Cfg, *starter.Node, starter.Runner)

err = bs.StartCluster(*starter.Cfg)

if err != nil {
Expand Down Expand Up @@ -261,6 +262,12 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
exit.WithError("Failed to enable container runtime", err)
}

if driver.IsKIC(cc.Driver) {
if err := cr.ForceSystemdCgroupManager(); err != nil {
glog.Warningf("Failed to force %s to use systemd as cgroup manager (this might be ok): %v", cr.Name(), err)
}
}

return cr
}

Expand Down