@@ -182,16 +182,26 @@ func runJoin(ctx context.Context, name string, flags JoinCmdFlags, jcmd *kotsadm
182182 return err
183183 }
184184
185- if isWorker {
186- logrus .Debugf ("worker node join finished" )
187- return nil
188- }
189-
190185 kcli , err := kubeutils .KubeClient ()
191186 if err != nil {
192187 return fmt .Errorf ("unable to get kube client: %w" , err )
193188 }
194189
190+ hostname , err := os .Hostname ()
191+ if err != nil {
192+ return fmt .Errorf ("unable to get hostname: %w" , err )
193+ }
194+
195+ logrus .Debugf ("waiting for node to join cluster" )
196+ if err := waitForNodeToJoin (ctx , kcli , hostname , isWorker ); err != nil {
197+ return fmt .Errorf ("unable to wait for node: %w" , err )
198+ }
199+
200+ if isWorker {
201+ logrus .Debugf ("worker node join finished" )
202+ return nil
203+ }
204+
195205 airgapChartsPath := ""
196206 if flags .isAirgap {
197207 airgapChartsPath = runtimeconfig .EmbeddedClusterChartsSubDir ()
@@ -207,15 +217,6 @@ func runJoin(ctx context.Context, name string, flags JoinCmdFlags, jcmd *kotsadm
207217 }
208218 defer hcli .Close ()
209219
210- hostname , err := os .Hostname ()
211- if err != nil {
212- return fmt .Errorf ("unable to get hostname: %w" , err )
213- }
214-
215- if err := waitForNodeToJoin (ctx , kcli , hostname ); err != nil {
216- return fmt .Errorf ("unable to wait for node: %w" , err )
217- }
218-
219220 if flags .enableHighAvailability {
220221 if err := maybeEnableHA (ctx , kcli , hcli , flags .isAirgap , cidrCfg .ServiceCIDR , jcmd .InstallationSpec .Proxy , jcmd .InstallationSpec .Config ); err != nil {
221222 return fmt .Errorf ("unable to enable high availability: %w" , err )
@@ -246,7 +247,12 @@ func runJoinVerifyAndPrompt(name string, flags JoinCmdFlags, jcmd *kotsadm.JoinC
246247 }
247248
248249 runtimeconfig .Set (jcmd .InstallationSpec .RuntimeConfig )
249- os .Setenv ("KUBECONFIG" , runtimeconfig .PathToKubeConfig ())
250+ isWorker := ! strings .Contains (jcmd .K0sJoinCommand , "controller" )
251+ if isWorker {
252+ os .Setenv ("KUBECONFIG" , runtimeconfig .PathToKubeletConfig ())
253+ } else {
254+ os .Setenv ("KUBECONFIG" , runtimeconfig .PathToKubeConfig ())
255+ }
250256 os .Setenv ("TMPDIR" , runtimeconfig .EmbeddedClusterTmpSubDir ())
251257
252258 if err := runtimeconfig .WriteToDisk (); err != nil {
@@ -476,11 +482,11 @@ func runK0sInstallCommand(networkInterface string, fullcmd string) error {
476482 return nil
477483}
478484
479- func waitForNodeToJoin (ctx context.Context , kcli client.Client , hostname string ) error {
485+ func waitForNodeToJoin (ctx context.Context , kcli client.Client , hostname string , isWorker bool ) error {
480486 loading := spinner .Start ()
481487 defer loading .Close ()
482488 loading .Infof ("Waiting for node to join the cluster" )
483- if err := kubeutils .WaitForControllerNode (ctx , kcli , hostname ); err != nil {
489+ if err := kubeutils .WaitForNode (ctx , kcli , hostname , isWorker ); err != nil {
484490 return fmt .Errorf ("unable to wait for node: %w" , err )
485491 }
486492 loading .Infof ("Node has joined the cluster!" )
0 commit comments