Skip to content

Commit 965a58b

Browse files
authored
Revert "feat: wait for coredns and metrics-server" (#623)
Revert "feat: wait for coredns and metrics-server (#621)" This reverts commit 0b7606f.
1 parent 0b7606f commit 965a58b

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

pkg/addons/applier.go

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ package addons
66
import (
77
"context"
88
"fmt"
9+
"time"
10+
911
"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
1012
k0sconfig "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
1113
embeddedclusterv1beta1 "github.com/replicatedhq/embedded-cluster-kinds/apis/v1beta1"
1214
"github.com/replicatedhq/embedded-cluster-kinds/types"
1315
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
1416
"github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
1517
"github.com/sirupsen/logrus"
18+
corev1 "k8s.io/api/core/v1"
1619
"sigs.k8s.io/controller-runtime/pkg/client"
1720

1821
"github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole"
@@ -59,12 +62,6 @@ func (a *Applier) Outro(ctx context.Context) error {
5962
if err != nil {
6063
return fmt.Errorf("unable to load addons: %w", err)
6164
}
62-
63-
err = a.waitForKubernetes(ctx, kcli)
64-
if err != nil {
65-
return fmt.Errorf("unable to wait for kubernetes: %w", err)
66-
}
67-
6865
for _, addon := range addons {
6966
if err := addon.Outro(ctx, kcli); err != nil {
7067
return err
@@ -322,29 +319,37 @@ func (a *Applier) Versions(additionalCharts []v1beta1.Chart) (map[string]string,
322319
return versions, nil
323320
}
324321

325-
// waitForKubernetes waits for coredns and metrics-server to be ready in kube-system.
326-
func (a *Applier) waitForKubernetes(ctx context.Context, cli client.Client) error {
322+
// waitForKubernetes waits until we manage to make a successful connection to the
323+
// Kubernetes API server.
324+
func (a *Applier) waitForKubernetes(ctx context.Context) error {
327325
loading := spinner.Start()
328-
loading.Infof("Waiting for Kubernetes System Infrastructure to be ready 0/2")
329-
330-
err := kubeutils.WaitForDeployment(ctx, cli, "kube-system", "coredns")
331-
if err != nil {
332-
loading.Errorf("CoreDNS failed to become healthy, check your /etc/resolv.conf configuration")
333-
loading.CloseWithError()
334-
return fmt.Errorf("unable to wait for CoreDNS: %w", err)
335-
}
336-
337-
loading.Infof("Waiting for Kubernetes System Infrastructure to be ready 1/2")
338-
339-
err = kubeutils.WaitForDeployment(ctx, cli, "kube-system", "metrics-server")
326+
defer func() {
327+
loading.Closef("Kubernetes API server is ready")
328+
}()
329+
kcli, err := kubeutils.KubeClient()
340330
if err != nil {
341-
loading.Errorf("Metrics Server failed to become healthy - this may be a firewall or network issue.")
342-
loading.CloseWithError()
343-
return fmt.Errorf("unable to wait for Metrics Server: %w", err)
331+
return fmt.Errorf("unable to create kubernetes client: %w", err)
332+
}
333+
ticker := time.NewTicker(3 * time.Second)
334+
defer ticker.Stop()
335+
counter := 1
336+
loading.Infof("1/n Waiting for Kubernetes API server to be ready")
337+
for {
338+
select {
339+
case <-ticker.C:
340+
case <-ctx.Done():
341+
return ctx.Err()
342+
}
343+
counter++
344+
if err := kcli.List(ctx, &corev1.NamespaceList{}); err != nil {
345+
loading.Infof(
346+
"%d/n Waiting for Kubernetes API server to be ready.",
347+
counter,
348+
)
349+
continue
350+
}
351+
return nil
344352
}
345-
346-
loading.Closef("Kubernetes System Infrastructure ready")
347-
return nil
348353
}
349354

350355
func spinForInstallation(ctx context.Context, cli client.Client) error {

0 commit comments

Comments
 (0)