diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index 96a21807fd2c0a7f84ef914197d32a9081ce80ae..a0b2163cb74e0728ec04e00e9575df100caed283 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -51,6 +51,7 @@ import ( "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/cruntime" "k8s.io/minikube/pkg/minikube/driver" + "k8s.io/minikube/pkg/minikube/kubeconfig" "k8s.io/minikube/pkg/minikube/machine" "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/minikube/out/register" @@ -538,6 +539,12 @@ func (k *Bootstrapper) restartControlPlane(cfg config.ClusterConfig) error { return errors.Wrap(err, "control plane") } + // Save the costly tax of reinstalling Kubernetes if the only issue is a missing kube context + _, err = kubeconfig.UpdateEndpoint(cfg.Name, hostname, port, kubeconfig.PathFromEnv()) + if err != nil { + glog.Warningf("unable to update kubeconfig (cluster will likely require a reset): %v", err) + } + client, err := k.client(hostname, port) if err != nil { return errors.Wrap(err, "getting k8s client") diff --git a/pkg/minikube/kubeconfig/kubeconfig.go b/pkg/minikube/kubeconfig/kubeconfig.go index 5cda239f2ce55022f6b7a687288888ffaf3ad03c..fc2a09e6fad000581fd9ea9aef2cb5e2fb953c85 100644 --- a/pkg/minikube/kubeconfig/kubeconfig.go +++ b/pkg/minikube/kubeconfig/kubeconfig.go @@ -125,6 +125,7 @@ func UpdateEndpoint(contextName string, hostname string, port int, confpath stri // if the cluster setting is missed in the kubeconfig, create new one if _, ok := cfg.Clusters[contextName]; !ok { + glog.Infof("%q context is missing from %s - will repair!", contextName, confpath) lp := localpath.Profile(contextName) gp := localpath.MiniPath() kcs := &Settings{