Skip to content

Commit

Permalink
Merge pull request #2013 from wenwenxiong/master
Browse files Browse the repository at this point in the history
make docker and containerd no parent-child process relationship
  • Loading branch information
ks-ci-bot authored Jan 5, 2024
2 parents d323bfc + 913e73e commit b2fd070
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
13 changes: 13 additions & 0 deletions cmd/kk/pkg/container/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ func (s *SyncDockerBinaries) Execute(runtime connector.Runtime) error {
return nil
}

type EnableContainerdForDocker struct {
common.KubeAction
}

func (e *EnableContainerdForDocker) Execute(runtime connector.Runtime) error {
if _, err := runtime.GetRunner().SudoCmd(
"systemctl daemon-reload && systemctl enable containerd && systemctl start containerd",
false); err != nil {
return errors.Wrap(errors.WithStack(err), fmt.Sprintf("enable and start containerd failed"))
}
return nil
}

type EnableDocker struct {
common.KubeAction
}
Expand Down
29 changes: 29 additions & 0 deletions cmd/kk/pkg/container/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ func InstallDocker(m *InstallContainerModule) []task.Interface {
Retry: 2,
}

generateContainerdService := &task.RemoteTask{
Name: "GenerateContainerdService",
Desc: "Generate containerd service",
Hosts: m.Runtime.GetHostsByRole(common.K8s),
Prepare: &prepare.PrepareCollection{
&kubernetes.NodeInCluster{Not: true},
&ContainerdExist{Not: true},
},
Action: &action.Template{
Template: templates.ContainerdService,
Dst: filepath.Join("/etc/systemd/system", templates.ContainerdService.Name()),
},
Parallel: true,
}

generateDockerService := &task.RemoteTask{
Name: "GenerateDockerService",
Desc: "Generate docker service",
Expand Down Expand Up @@ -109,6 +124,18 @@ func InstallDocker(m *InstallContainerModule) []task.Interface {
Parallel: true,
}

enableContainerdForDocker := &task.RemoteTask{
Name: "EnableContainerd",
Desc: "Enable containerd",
Hosts: m.Runtime.GetHostsByRole(common.K8s),
Prepare: &prepare.PrepareCollection{
&kubernetes.NodeInCluster{Not: true},
&ContainerdExist{Not: true},
},
Action: new(EnableContainerdForDocker),
Parallel: true,
}

enableDocker := &task.RemoteTask{
Name: "EnableDocker",
Desc: "Enable docker",
Expand Down Expand Up @@ -136,8 +163,10 @@ func InstallDocker(m *InstallContainerModule) []task.Interface {

return []task.Interface{
syncBinaries,
generateContainerdService,
generateDockerService,
generateDockerConfig,
enableContainerdForDocker,
enableDocker,
dockerLoginRegistry,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/kk/pkg/container/templates/docker_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecStart=/usr/bin/dockerd --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Expand Down

0 comments on commit b2fd070

Please sign in to comment.