kubeadm: fix dry-run for kubelet-wait-bootstrap phase

This commit is contained in:
Christian Schlotter 2025-02-03 14:46:27 +01:00
parent 20fbdeac96
commit 6c093b1699
No known key found for this signature in database
GPG Key ID: 0E487122453EB0AC
2 changed files with 48 additions and 35 deletions

View File

@ -609,7 +609,9 @@ func (j *joinData) Client() (clientset.Interface, error) {
AppendReactor(dryRun.GetKubeadmConfigReactor()).
AppendReactor(dryRun.GetKubeadmCertsReactor()).
AppendReactor(dryRun.GetKubeProxyConfigReactor()).
AppendReactor(dryRun.GetKubeletConfigReactor())
AppendReactor(dryRun.GetKubeletConfigReactor()).
AppendReactor(dryRun.GetNodeReactor()).
AppendReactor(dryRun.PatchNodeReactor())
j.client = dryRun.FakeClient()
return j.client, nil

View File

@ -293,6 +293,16 @@ func runKubeletWaitBootstrapPhase(c workflow.RunData) (returnErr error) {
return err
}
var client clientset.Interface
if data.DryRun() {
fmt.Println("[kubelet-wait] Would wait for the kubelet to be bootstrapped")
// Use the dry-run client.
if client, err = data.Client(); err != nil {
return errors.Wrap(err, "could not get client for dry-run")
}
} else {
bootstrapKubeConfigFile := filepath.Join(data.KubeConfigDir(), kubeadmconstants.KubeletBootstrapKubeConfigFileName)
// Deletes the bootstrapKubeConfigFile, so the credential used for TLS bootstrap is removed from disk
defer func() {
@ -328,10 +338,11 @@ func runKubeletWaitBootstrapPhase(c workflow.RunData) (returnErr error) {
}
// When we know the /etc/kubernetes/kubelet.conf file is available, get the client
client, err := kubeconfigutil.ClientSetFromFile(kubeadmconstants.GetKubeletKubeConfigPath())
client, err = kubeconfigutil.ClientSetFromFile(kubeadmconstants.GetKubeletKubeConfigPath())
if err != nil {
return err
}
}
if !features.Enabled(initCfg.ClusterConfiguration.FeatureGates, features.NodeLocalCRISocket) {
klog.V(1).Infoln("[kubelet-start] preserving the crisocket information for the node")