From c7e7fba4c6f815e47795f9c9bac34dda8d93eaff Mon Sep 17 00:00:00 2001 From: Nils Hanke Date: Tue, 14 Mar 2023 12:25:04 +0100 Subject: [PATCH] bootstrapper: create /etc/kubernetes/manifests for all nodes --- .../internal/kubernetes/k8sapi/k8sutil.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bootstrapper/internal/kubernetes/k8sapi/k8sutil.go b/bootstrapper/internal/kubernetes/k8sapi/k8sutil.go index 5e3b4701e..d5b525e6b 100644 --- a/bootstrapper/internal/kubernetes/k8sapi/k8sutil.go +++ b/bootstrapper/internal/kubernetes/k8sapi/k8sutil.go @@ -140,6 +140,12 @@ func (k *KubernetesUtil) InitCluster( return nil, fmt.Errorf("creating signed kubelete certificate: %w", err) } + // Create static pods directory for all nodes (the Kubelets on the worker nodes also expect the path to exist) + log.Infof("Creating static Pod directory /etc/kubernetes/manifests") + if err := os.MkdirAll("/etc/kubernetes/manifests", os.ModePerm); err != nil { + return nil, fmt.Errorf("creating static pods directory: %w", err) + } + log.Infof("Preparing node for Konnectivity") if err := k.prepareControlPlaneForKonnectivity(ctx, controlPlaneEndpoint); err != nil { return nil, fmt.Errorf("setup konnectivity: %w", err) @@ -187,10 +193,6 @@ func (k *KubernetesUtil) prepareControlPlaneForKonnectivity(ctx context.Context, loadBalancerEndpoint = net.JoinHostPort(loadBalancerEndpoint, strconv.Itoa(constants.KubernetesPort)) } - if err := os.MkdirAll("/etc/kubernetes/manifests", os.ModePerm); err != nil { - return fmt.Errorf("creating static pods directory: %w", err) - } - konnectivityServerYaml, err := resources.NewKonnectivityServerStaticPod().Marshal() if err != nil { return fmt.Errorf("generating konnectivity server static pod: %w", err) @@ -328,6 +330,12 @@ func (k *KubernetesUtil) JoinCluster(ctx context.Context, joinConfig []byte, pee return fmt.Errorf("writing kubeadm init yaml config %v: %w", joinConfigFile.Name(), err) } + // Create static pods directory for all nodes (the Kubelets on the worker nodes also expect the path to exist) + log.Infof("Creating static Pod directory /etc/kubernetes/manifests") + if err := os.MkdirAll("/etc/kubernetes/manifests", os.ModePerm); err != nil { + return fmt.Errorf("creating static pods directory: %w", err) + } + if peerRole == role.ControlPlane { log.Infof("Prep Init Kubernetes cluster") if err := k.prepareControlPlaneForKonnectivity(ctx, controlPlaneEndpoint); err != nil {