Skip to content

Commit

Permalink
Add handling for cri-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmasi committed May 28, 2024
1 parent 489aaeb commit 78a83df
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
pullRetryDelay = time.Second
poolRetryDelay = 5 * time.Second
healthTimeout = time.Minute
criDocker = "cri-docker"

// Stubs for testing.
execLookPath = exec.LookPath
Expand Down Expand Up @@ -445,6 +446,15 @@ func (k *KubeadmSpec) Deploy(ctx context.Context) error {
args := []string{"kubeadm", "init"}
if k.CRISocket != "" {
args = append(args, "--cri-socket", k.CRISocket)
// If using cri-docker, then ensure the components are running.
if strings.Contains(k.CRISocket, criDocker) {
if err := run.LogCommand("sudo", "systemctl", "enable", "--now", criDocker+".socket"); err != nil {
return err
}
if err := run.LogCommand("sudo", "systemctl", "enable", "--now", criDocker+".service"); err != nil {
return err
}
}
}
if k.PodNetworkCIDR != "" {
args = append(args, "--pod-network-cidr", k.PodNetworkCIDR)
Expand Down
12 changes: 12 additions & 0 deletions deploy/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ func TestKubeadmSpec(t *testing.T) {
{Cmd: "sudo", Args: []string{"cat", "/etc/kubernetes/admin.conf"}},
{Cmd: "docker", Args: []string{"network", "create", "kne-kubeadm-.*"}},
},
}, {
desc: "use cri-docker",
k: &KubeadmSpec{
CRISocket: "unix:///var/run/cri-dockerd.sock",
},
resp: []fexec.Response{
{Cmd: "sudo", Args: []string{"systemctl", "enable", "--now", "cri-docker.socket"}},
{Cmd: "sudo", Args: []string{"systemctl", "enable", "--now", "cri-docker.service"}},
{Cmd: "sudo", Args: []string{"kubeadm", "init", "--cri-socket", "unix:///var/run/cri-dockerd.sock"}},
{Cmd: "sudo", Args: []string{"cat", "/etc/kubernetes/admin.conf"}},
{Cmd: "docker", Args: []string{"network", "create", "kne-kubeadm-.*"}},
},
}, {
desc: "allow control plane scheduling",
k: &KubeadmSpec{
Expand Down

0 comments on commit 78a83df

Please sign in to comment.