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

WIP: Run kubeadm init phase addon all to ensure kube-proxy is up in v1.13+ #4014

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 17 additions & 6 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (k *Bootstrapper) StartCluster(k8s config.KubernetesConfig) error {
}
}

if err := waitForPods(k8s, false); err != nil {
if err := waitForPods(k8s, false, false); err != nil {
return errors.Wrap(err, "wait")
}

Expand All @@ -227,7 +227,7 @@ func (k *Bootstrapper) StartCluster(k8s config.KubernetesConfig) error {
}

// Make sure elevating privileges didn't screw anything up
if err := waitForPods(k8s, true); err != nil {
if err := waitForPods(k8s, true, false); err != nil {
return errors.Wrap(err, "wait")
}

Expand Down Expand Up @@ -264,11 +264,11 @@ func addAddons(files *[]assets.CopyableFile, data interface{}) error {
}

// waitForPods waits until the important Kubernetes pods are in running state
func waitForPods(k8s config.KubernetesConfig, quiet bool) error {
func waitForPods(k8s config.KubernetesConfig, quiet bool, componentsOnly bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having two bool arguments to a function is a bad code smell. Do you mind splitting this out into two functions? Perhaps something like:

waitForComponentPods and waitFork8sPods?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

// Do not wait for "k8s-app" pods in the case of CNI, as they are managed
// by a CNI plugin which is usually started after minikube has been brought
// up. Otherwise, minikube won't start, as "k8s-app" pods are not ready.
componentsOnly := k8s.NetworkPlugin == "cni"
componentsOnly = k8s.NetworkPlugin == "cni" || componentsOnly

if !quiet {
console.OutStyle("waiting-pods", "Waiting for pods:")
Expand Down Expand Up @@ -325,7 +325,18 @@ func (k *Bootstrapper) RestartCluster(k8s config.KubernetesConfig) error {
}
}

if err := waitForPods(k8s, false); err != nil {
if err := waitForPods(k8s, false, true); err != nil {
return errors.Wrap(err, "wait")
}

if version.GTE(semver.MustParse("1.13.0")) {
cmd := fmt.Sprintf("sudo kubeadm init phase addon all --config %s", constants.KubeadmConfigFile)
if err := k.c.Run(cmd); err != nil {
return errors.Wrapf(err, "running cmd: %s", cmd)
}
}

if err := waitForPods(k8s, false, false); err != nil {
return errors.Wrap(err, "wait")
}

Expand All @@ -335,7 +346,7 @@ func (k *Bootstrapper) RestartCluster(k8s config.KubernetesConfig) error {
}

// Make sure the kube-proxy restart didn't screw anything up.
if err := waitForPods(k8s, true); err != nil {
if err := waitForPods(k8s, true, false); err != nil {
return errors.Wrap(err, "wait")
}

Expand Down