Skip to content

Commit

Permalink
Updates to attempt several different kubeadm config paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Eagerod committed Mar 15, 2024
1 parent 5c3691e commit 245608f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pkg/hope/node_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,27 @@ func setupCommonNodeRequirements(log *logrus.Entry, node *Node) error {
return err
}

// Different versions of kubeabm will install their kubeadm.conf under
// different paths; take the first one found from known paths.
possibleKubeadmConfigPaths := []string{
"/usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf",
"/etc/systemd/system/kubelet.service.d/10-kubeadm.conf",
}

commandStr := ""
for _, p := range possibleKubeadmConfigPaths {
commandStr = fmt.Sprintf("%s if [ -f \"%s\" ]; then echo \"%s\"; exit; fi;", commandStr, p, p)
}

kubeadmConfigPath, err := ssh.GetSSH(connectionString, commandStr)
if err != nil {
return err
}

kubeadmConfigPath = strings.TrimSpace(kubeadmConfigPath)

// Make sure the Kubelet cgroups driver is also systemd.
if err := ssh.ExecSSH(connectionString, "sudo", "sed", "-i", "'s#Environment=\"KUBELET_CONFIG_ARGS=.*#Environment=\"KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml --cgroup-driver=systemd\"#g'", "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf"); err != nil {
if err := ssh.ExecSSH(connectionString, "sudo", "sed", "-i", "'s#Environment=\"KUBELET_CONFIG_ARGS=.*#Environment=\"KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml --cgroup-driver=systemd\"#g'", kubeadmConfigPath); err != nil {
return err
}

Expand Down

0 comments on commit 245608f

Please sign in to comment.