kubeadm: feature gate ControlPlaneKubeletLocalMode on init

This commit is contained in:
Christian Schlotter 2024-06-28 12:57:45 +02:00
parent 038a94804e
commit 241c1c7737
No known key found for this signature in database
GPG Key ID: 0E487122453EB0AC

View File

@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
"k8s.io/kubernetes/cmd/kubeadm/app/features"
kubeconfigphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig"
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
)
@ -157,7 +158,16 @@ func runKubeConfigFile(kubeConfigFileName string) func(workflow.RunData) error {
cfg.CertificatesDir = data.CertificateWriteDir()
defer func() { cfg.CertificatesDir = data.CertificateDir() }()
initConfiguration := data.Cfg().DeepCopy()
if features.Enabled(cfg.FeatureGates, features.ControlPlaneKubeletLocalMode) {
if kubeConfigFileName == kubeadmconstants.KubeletKubeConfigFileName {
// Unset the ControlPlaneEndpoint so the creation falls back to the LocalAPIEndpoint for the kubelet's kubeconfig.
initConfiguration.ControlPlaneEndpoint = ""
}
}
// creates the KubeConfig file (or use existing)
return kubeconfigphase.CreateKubeConfigFile(kubeConfigFileName, data.KubeConfigDir(), data.Cfg())
return kubeconfigphase.CreateKubeConfigFile(kubeConfigFileName, data.KubeConfigDir(), initConfiguration)
}
}