From 32a289701be23eba8bf9448962728027c9782e6e Mon Sep 17 00:00:00 2001 From: Marcos Diez Date: Wed, 17 Apr 2019 17:35:43 -0300 Subject: [PATCH] Don't load Minikube on boot when using the none driver --- cmd/minikube/cmd/start.go | 5 ++++- pkg/minikube/bootstrapper/bootstrapper.go | 2 +- pkg/minikube/bootstrapper/kubeadm/kubeadm.go | 10 ++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index f3ba1300b657..329f452d3774 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -496,7 +496,10 @@ func prepareHostEnvironment(api libmachine.API, kc cfg.KubernetesConfig) bootstr console.OutStyle("option", "%s.%s=%s", eo.Component, eo.Key, eo.Value) } // Loads cached images, generates config files, download binaries - if err := bs.UpdateCluster(kc); err != nil { + + autostart_cluster := viper.GetString(vmDriver) != constants.DriverNone + + if err := bs.UpdateCluster(kc, autostart_cluster); err != nil { exit.WithError("Failed to update cluster", err) } if err := bs.SetupCerts(kc); err != nil { diff --git a/pkg/minikube/bootstrapper/bootstrapper.go b/pkg/minikube/bootstrapper/bootstrapper.go index e69d79058202..27ed458e8a6c 100644 --- a/pkg/minikube/bootstrapper/bootstrapper.go +++ b/pkg/minikube/bootstrapper/bootstrapper.go @@ -36,7 +36,7 @@ type Bootstrapper interface { // PullImages pulls images necessary for a cluster. Success should not be required. PullImages(config.KubernetesConfig) error StartCluster(config.KubernetesConfig) error - UpdateCluster(config.KubernetesConfig) error + UpdateCluster(config.KubernetesConfig, bool) error RestartCluster(config.KubernetesConfig) error DeleteCluster(config.KubernetesConfig) error // LogCommands returns a map of log type to a command which will display that log. diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index 893668580d1e..ef0d2942e15b 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -424,7 +424,7 @@ func NewKubeletConfig(k8s config.KubernetesConfig, r cruntime.Manager) (string, } // UpdateCluster updates the cluster -func (k *Bootstrapper) UpdateCluster(cfg config.KubernetesConfig) error { +func (k *Bootstrapper) UpdateCluster(cfg config.KubernetesConfig, autostart_cluster bool) error { _, images := constants.GetKubeadmCachedImages(cfg.ImageRepository, cfg.KubernetesVersion) if cfg.ShouldLoadCachedImages { if err := machine.LoadImages(k.c, images, constants.ImageCacheDir); err != nil { @@ -464,13 +464,19 @@ func (k *Bootstrapper) UpdateCluster(cfg config.KubernetesConfig) error { } err = k.c.Run(` sudo systemctl daemon-reload && -sudo systemctl enable kubelet && sudo systemctl start kubelet `) if err != nil { return errors.Wrap(err, "starting kubelet") } + if autostart_cluster { + err = k.c.Run(`sudo systemctl enable kubelet`) + if err != nil { + return errors.Wrap(err, "making kubelet start on boot") + } + } + return nil }