@@ -21,14 +21,14 @@ import (
21
21
"path/filepath"
22
22
"strings"
23
23
24
- "github.com/pkg/errors"
25
-
26
24
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common"
27
25
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container/templates"
28
26
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector"
29
27
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/files"
30
28
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/registry"
31
29
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/utils"
30
+ "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/version/kubernetes"
31
+ "github.com/pkg/errors"
32
32
)
33
33
34
34
type SyncDockerBinaries struct {
@@ -64,6 +64,39 @@ func (s *SyncDockerBinaries) Execute(runtime connector.Runtime) error {
64
64
return nil
65
65
}
66
66
67
+ type SyncCriDockerdBinaries struct {
68
+ common.KubeAction
69
+ }
70
+
71
+ func (s * SyncCriDockerdBinaries ) Execute (runtime connector.Runtime ) error {
72
+ if err := utils .ResetTmpDir (runtime ); err != nil {
73
+ return err
74
+ }
75
+
76
+ binariesMapObj , ok := s .PipelineCache .Get (common .KubeBinaries + "-" + runtime .RemoteHost ().GetArch ())
77
+ if ! ok {
78
+ return errors .New ("get KubeBinary by pipeline cache failed" )
79
+ }
80
+ binariesMap := binariesMapObj .(map [string ]* files.KubeBinary )
81
+
82
+ criDockerd , ok := binariesMap [common .CriDockerd ]
83
+ if ! ok {
84
+ return errors .New ("get KubeBinary key cri-dockerd by pipeline cache failed" )
85
+ }
86
+
87
+ dst := filepath .Join (common .TmpDir , criDockerd .FileName )
88
+ if err := runtime .GetRunner ().Scp (criDockerd .Path (), dst ); err != nil {
89
+ return errors .Wrap (errors .WithStack (err ), fmt .Sprintf ("sync cri-dockerd binaries failed" ))
90
+ }
91
+
92
+ if _ , err := runtime .GetRunner ().SudoCmd (
93
+ fmt .Sprintf ("mkdir -p /usr/bin && tar -zxf %s && mv cri-dockerd/* /usr/bin && rm -rf cri-dockerd" , dst ),
94
+ false ); err != nil {
95
+ return errors .Wrap (errors .WithStack (err ), fmt .Sprintf ("install container runtime cri-dockerd binaries failed" ))
96
+ }
97
+ return nil
98
+ }
99
+
67
100
type EnableContainerdForDocker struct {
68
101
common.KubeAction
69
102
}
@@ -90,6 +123,19 @@ func (e *EnableDocker) Execute(runtime connector.Runtime) error {
90
123
return nil
91
124
}
92
125
126
+ type EnableCriDockerd struct {
127
+ common.KubeAction
128
+ }
129
+
130
+ func (e * EnableCriDockerd ) Execute (runtime connector.Runtime ) error {
131
+ if _ , err := runtime .GetRunner ().SudoCmd (
132
+ "systemctl daemon-reload && systemctl enable cri-docker && systemctl start cri-docker" ,
133
+ false ); err != nil {
134
+ return errors .Wrap (errors .WithStack (err ), fmt .Sprintf ("enable and start cri-docker failed" ))
135
+ }
136
+ return nil
137
+ }
138
+
93
139
type DockerLoginRegistry struct {
94
140
common.KubeAction
95
141
}
@@ -141,6 +187,15 @@ func (d *DisableDocker) Execute(runtime connector.Runtime) error {
141
187
filepath .Join ("/etc/systemd/system" , templates .DockerService .Name ()),
142
188
filepath .Join ("/etc/docker" , templates .DockerConfig .Name ()),
143
189
}
190
+
191
+ if kubernetes .IsAtLeastV124 (d .KubeConf .Cluster .Kubernetes .Version ) && d .KubeConf .Cluster .Kubernetes .ContainerManager == common .Docker {
192
+ if _ , err := runtime .GetRunner ().SudoCmd ("systemctl disable cri-docker && systemctl stop cri-docker" ,
193
+ false ); err != nil {
194
+ return errors .Wrap (errors .WithStack (err ), fmt .Sprintf ("disable and stop cri-docker failed" ))
195
+ }
196
+ files = append (files , filepath .Join ("/etc/systemd/system" , templates .CriDockerService .Name ()))
197
+ }
198
+
144
199
if d .KubeConf .Cluster .Registry .DataRoot != "" {
145
200
files = append (files , d .KubeConf .Cluster .Registry .DataRoot )
146
201
} else {
0 commit comments