From 3dd2717a86e5b9e812eec35bdc730565ba144827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Fri, 13 Apr 2018 07:55:01 +0200 Subject: [PATCH] Use --skip-preflight-checks for k8s < 1.9 --- pkg/minikube/bootstrapper/kubeadm/kubeadm.go | 18 ++++++++++++++---- pkg/minikube/bootstrapper/kubeadm/templates.go | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index dfd96cfe44e7..a2947fc2c564 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -26,6 +26,7 @@ import ( "strings" "time" + "github.com/blang/semver" "github.com/docker/machine/libmachine" "github.com/docker/machine/libmachine/state" "github.com/golang/glog" @@ -111,13 +112,22 @@ func (k *KubeadmBootstrapper) StartCluster(k8s config.KubernetesConfig) error { // (it should probably stop doing this, though...) // We use --ignore-preflight-errors=CRI since /var/run/dockershim.sock is not present. // (because we start kubelet with an invalid config) + version, err := ParseKubernetesVersion(k8s.KubernetesVersion) + if err != nil { + return errors.Wrap(err, "parsing kubernetes version") + } + b := bytes.Buffer{} templateContext := struct { - KubeadmConfigFile string - Preflights []string + KubeadmConfigFile string + SkipPreflightChecks bool + Preflights []string }{ - KubeadmConfigFile: constants.KubeadmConfigFile, - Preflights: constants.Preflights, + KubeadmConfigFile: constants.KubeadmConfigFile, + SkipPreflightChecks: !VersionIsBetween(version, + semver.MustParse("1.9.0-alpha.0"), + semver.Version{}), + Preflights: constants.Preflights, } if err := kubeadmInitTemplate.Execute(&b, templateContext); err != nil { return err diff --git a/pkg/minikube/bootstrapper/kubeadm/templates.go b/pkg/minikube/bootstrapper/kubeadm/templates.go index c88750895038..90ff5a6a14de 100644 --- a/pkg/minikube/bootstrapper/kubeadm/templates.go +++ b/pkg/minikube/bootstrapper/kubeadm/templates.go @@ -72,7 +72,7 @@ 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}} {{range .Preflights}}--ignore-preflight-errors={{.}} {{end}}")) + "sudo /usr/bin/kubeadm init --config {{.KubeadmConfigFile}} {{if .SkipPreflightChecks}}--skip-preflight-checks{{else}}{{range .Preflights}}--ignore-preflight-errors={{.}} {{end}}{{end}}")) // printMapInOrder sorts the keys and prints the map in order, combining key // value pairs with the separator character