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

Update kubeadm restart commands to support v1.13.x #3483

Merged
merged 3 commits into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 19 additions & 9 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,31 @@ func addAddons(files *[]assets.CopyableFile) error {
}

func (k *KubeadmBootstrapper) RestartCluster(k8s config.KubernetesConfig) error {
opts := struct {
KubeadmConfigFile string
}{
KubeadmConfigFile: constants.KubeadmConfigFile,
version, err := ParseKubernetesVersion(k8s.KubernetesVersion)
if err != nil {
return errors.Wrap(err, "parsing kubernetes version")
}

b := bytes.Buffer{}
if err := kubeadmRestoreTemplate.Execute(&b, opts); err != nil {
return err
phase := "alpha"
controlPlane := "controlplane"
if version.GTE(semver.MustParse("1.13.0")) {
phase = "init"
controlPlane = "control-plane"
}

if err := k.c.Run(b.String()); err != nil {
return errors.Wrapf(err, "running cmd: %s", b.String())
cmds := []string{
fmt.Sprintf("sudo kubeadm %s phase certs all --config %s", phase, constants.KubeadmConfigFile),
fmt.Sprintf("sudo kubeadm %s phase kubeconfig all --config %s", phase, constants.KubeadmConfigFile),
fmt.Sprintf("sudo kubeadm %s phase %s all --config %s", phase, controlPlane, constants.KubeadmConfigFile),
fmt.Sprintf("sudo kubeadm %s phase etcd local --config %s", phase, constants.KubeadmConfigFile),
}

// Run commands one at a time so that it is easier to root cause failures.
for _, cmd := range cmds {
if err := k.c.Run(cmd); err != nil {
return errors.Wrapf(err, "running cmd: %s", cmd)
}
}
if err := restartKubeProxy(k8s); err != nil {
return errors.Wrap(err, "restarting kube-proxy")
}
Expand Down
7 changes: 0 additions & 7 deletions pkg/minikube/bootstrapper/kubeadm/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ RestartSec=10
WantedBy=multi-user.target
`

var kubeadmRestoreTemplate = template.Must(template.New("kubeadmRestoreTemplate").Parse(`
sudo kubeadm alpha phase certs all --config {{.KubeadmConfigFile}} &&
sudo /usr/bin/kubeadm alpha phase kubeconfig all --config {{.KubeadmConfigFile}} &&
sudo /usr/bin/kubeadm alpha phase controlplane all --config {{.KubeadmConfigFile}} &&
sudo /usr/bin/kubeadm alpha phase etcd local --config {{.KubeadmConfigFile}}
`))

var kubeadmInitTemplate = template.Must(template.New("kubeadmInitTemplate").Parse(`
sudo /usr/bin/kubeadm init --config {{.KubeadmConfigFile}} {{if .SkipPreflightChecks}}--skip-preflight-checks{{else}}{{range .Preflights}}--ignore-preflight-errors={{.}} {{end}}{{end}}
`))
Expand Down