bootstrapper: create /etc/kubernetes/manifests for all nodes

This commit is contained in:
Nils Hanke 2023-03-14 12:25:04 +01:00 committed by Nils Hanke
parent 6bb6f1c288
commit c7e7fba4c6

View File

@ -140,6 +140,12 @@ func (k *KubernetesUtil) InitCluster(
return nil, fmt.Errorf("creating signed kubelete certificate: %w", err) 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") log.Infof("Preparing node for Konnectivity")
if err := k.prepareControlPlaneForKonnectivity(ctx, controlPlaneEndpoint); err != nil { if err := k.prepareControlPlaneForKonnectivity(ctx, controlPlaneEndpoint); err != nil {
return nil, fmt.Errorf("setup konnectivity: %w", err) 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)) 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() konnectivityServerYaml, err := resources.NewKonnectivityServerStaticPod().Marshal()
if err != nil { if err != nil {
return fmt.Errorf("generating konnectivity server static pod: %w", err) 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) 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 { if peerRole == role.ControlPlane {
log.Infof("Prep Init Kubernetes cluster") log.Infof("Prep Init Kubernetes cluster")
if err := k.prepareControlPlaneForKonnectivity(ctx, controlPlaneEndpoint); err != nil { if err := k.prepareControlPlaneForKonnectivity(ctx, controlPlaneEndpoint); err != nil {