@@ -293,44 +293,55 @@ func runKubeletWaitBootstrapPhase(c workflow.RunData) (returnErr error) {
293
293
return err
294
294
}
295
295
296
- bootstrapKubeConfigFile := filepath .Join (data .KubeConfigDir (), kubeadmconstants .KubeletBootstrapKubeConfigFileName )
297
- // Deletes the bootstrapKubeConfigFile, so the credential used for TLS bootstrap is removed from disk
298
- defer func () {
299
- _ = os .Remove (bootstrapKubeConfigFile )
300
- }()
301
-
302
- // Apply patches to the in-memory kubelet configuration so that any configuration changes like kubelet healthz
303
- // address and port options are respected during the wait below. WriteConfigToDisk already applied patches to
304
- // the kubelet.yaml written to disk. This should be done after WriteConfigToDisk because both use the same config
305
- // in memory and we don't want patches to be applied two times to the config that is written to disk.
306
- if err := kubeletphase .ApplyPatchesToConfig (& initCfg .ClusterConfiguration , data .PatchesDir ()); err != nil {
307
- return errors .Wrap (err , "could not apply patches to the in-memory kubelet configuration" )
308
- }
296
+ var client clientset.Interface
309
297
310
- // Now the kubelet will perform the TLS Bootstrap, transforming /etc/kubernetes/bootstrap-kubelet.conf to /etc/kubernetes/kubelet.conf
311
- // Wait for the kubelet to create the /etc/kubernetes/kubelet.conf kubeconfig file. If this process
312
- // times out, display a somewhat user-friendly message.
313
- waiter := apiclient .NewKubeWaiter (nil , 0 , os .Stdout )
314
- waiter .SetTimeout (cfg .Timeouts .KubeletHealthCheck .Duration )
315
- kubeletConfig := initCfg .ClusterConfiguration .ComponentConfigs [componentconfigs .KubeletGroup ].Get ()
316
- kubeletConfigTyped , ok := kubeletConfig .(* kubeletconfig.KubeletConfiguration )
317
- if ! ok {
318
- return errors .New ("could not convert the KubeletConfiguration to a typed object" )
319
- }
320
- if err := waiter .WaitForKubelet (kubeletConfigTyped .HealthzBindAddress , * kubeletConfigTyped .HealthzPort ); err != nil {
321
- fmt .Printf (kubeadmJoinFailMsg , err )
322
- return err
323
- }
298
+ if data .DryRun () {
299
+ fmt .Println ("[kubelet-wait] Would wait for the kubelet to be bootstrapped" )
324
300
325
- if err := waitForTLSBootstrappedClient (cfg .Timeouts .TLSBootstrap .Duration ); err != nil {
326
- fmt .Printf (kubeadmJoinFailMsg , err )
327
- return err
328
- }
301
+ // Use the dry-run client.
302
+ if client , err = data .Client (); err != nil {
303
+ return errors .Wrap (err , "could not get client for dry-run" )
304
+ }
305
+ } else {
306
+ bootstrapKubeConfigFile := filepath .Join (data .KubeConfigDir (), kubeadmconstants .KubeletBootstrapKubeConfigFileName )
307
+ // Deletes the bootstrapKubeConfigFile, so the credential used for TLS bootstrap is removed from disk
308
+ defer func () {
309
+ _ = os .Remove (bootstrapKubeConfigFile )
310
+ }()
329
311
330
- // When we know the /etc/kubernetes/kubelet.conf file is available, get the client
331
- client , err := kubeconfigutil .ClientSetFromFile (kubeadmconstants .GetKubeletKubeConfigPath ())
332
- if err != nil {
333
- return err
312
+ // Apply patches to the in-memory kubelet configuration so that any configuration changes like kubelet healthz
313
+ // address and port options are respected during the wait below. WriteConfigToDisk already applied patches to
314
+ // the kubelet.yaml written to disk. This should be done after WriteConfigToDisk because both use the same config
315
+ // in memory and we don't want patches to be applied two times to the config that is written to disk.
316
+ if err := kubeletphase .ApplyPatchesToConfig (& initCfg .ClusterConfiguration , data .PatchesDir ()); err != nil {
317
+ return errors .Wrap (err , "could not apply patches to the in-memory kubelet configuration" )
318
+ }
319
+
320
+ // Now the kubelet will perform the TLS Bootstrap, transforming /etc/kubernetes/bootstrap-kubelet.conf to /etc/kubernetes/kubelet.conf
321
+ // Wait for the kubelet to create the /etc/kubernetes/kubelet.conf kubeconfig file. If this process
322
+ // times out, display a somewhat user-friendly message.
323
+ waiter := apiclient .NewKubeWaiter (nil , 0 , os .Stdout )
324
+ waiter .SetTimeout (cfg .Timeouts .KubeletHealthCheck .Duration )
325
+ kubeletConfig := initCfg .ClusterConfiguration .ComponentConfigs [componentconfigs .KubeletGroup ].Get ()
326
+ kubeletConfigTyped , ok := kubeletConfig .(* kubeletconfig.KubeletConfiguration )
327
+ if ! ok {
328
+ return errors .New ("could not convert the KubeletConfiguration to a typed object" )
329
+ }
330
+ if err := waiter .WaitForKubelet (kubeletConfigTyped .HealthzBindAddress , * kubeletConfigTyped .HealthzPort ); err != nil {
331
+ fmt .Printf (kubeadmJoinFailMsg , err )
332
+ return err
333
+ }
334
+
335
+ if err := waitForTLSBootstrappedClient (cfg .Timeouts .TLSBootstrap .Duration ); err != nil {
336
+ fmt .Printf (kubeadmJoinFailMsg , err )
337
+ return err
338
+ }
339
+
340
+ // When we know the /etc/kubernetes/kubelet.conf file is available, get the client
341
+ client , err = kubeconfigutil .ClientSetFromFile (kubeadmconstants .GetKubeletKubeConfigPath ())
342
+ if err != nil {
343
+ return err
344
+ }
334
345
}
335
346
336
347
if ! features .Enabled (initCfg .ClusterConfiguration .FeatureGates , features .NodeLocalCRISocket ) {
0 commit comments