@@ -144,6 +144,11 @@ var joinCommand = &cli.Command{
144
144
Usage : "Enable high availability." ,
145
145
Hidden : true ,
146
146
},
147
+ & cli.StringFlag {
148
+ Name : "network-interface" ,
149
+ Usage : "The network interface to use for the cluster" ,
150
+ Value : "" ,
151
+ },
147
152
& cli.BoolFlag {
148
153
Name : "no-prompt" ,
149
154
Usage : "Disable interactive prompts." ,
@@ -181,13 +186,6 @@ var joinCommand = &cli.Command{
181
186
return fmt .Errorf ("usage: %s join <url> <token>" , binName )
182
187
}
183
188
184
- logrus .Debugf ("getting network interface from join command" )
185
- jcmdAddress := strings .Split (c .Args ().Get (0 ), ":" )[0 ]
186
- networkInterface , err := netutils .InterfaceNameForAddress (jcmdAddress )
187
- if err != nil {
188
- return fmt .Errorf ("unable to get network interface for address %s: %w" , jcmdAddress , err )
189
- }
190
-
191
189
logrus .Debugf ("fetching join token remotely" )
192
190
jcmd , err := getJoinToken (c .Context , c .Args ().Get (0 ), c .Args ().Get (1 ))
193
191
if err != nil {
@@ -200,7 +198,7 @@ var joinCommand = &cli.Command{
200
198
}
201
199
202
200
setProxyEnv (jcmd .InstallationSpec .Proxy )
203
- proxyOK , localIP , err := checkProxyConfigForLocalIP (jcmd .InstallationSpec .Proxy , networkInterface )
201
+ proxyOK , localIP , err := checkProxyConfigForLocalIP (jcmd .InstallationSpec .Proxy , c . String ( "network-interface" ) )
204
202
if err != nil {
205
203
return fmt .Errorf ("failed to check proxy config for local IP: %w" , err )
206
204
}
@@ -279,7 +277,7 @@ var joinCommand = &cli.Command{
279
277
}
280
278
281
279
logrus .Debugf ("overriding network configuration" )
282
- if err := applyNetworkConfiguration (jcmd , networkInterface ); err != nil {
280
+ if err := applyNetworkConfiguration (c , jcmd ); err != nil {
283
281
err := fmt .Errorf ("unable to apply network configuration: %w" , err )
284
282
metrics .ReportJoinFailed (c .Context , jcmd .InstallationSpec .MetricsBaseURL , jcmd .ClusterID , err )
285
283
}
@@ -292,7 +290,7 @@ var joinCommand = &cli.Command{
292
290
}
293
291
294
292
logrus .Debugf ("joining node to cluster" )
295
- if err := runK0sInstallCommand (jcmd .K0sJoinCommand , networkInterface ); err != nil {
293
+ if err := runK0sInstallCommand (c , jcmd .K0sJoinCommand ); err != nil {
296
294
err := fmt .Errorf ("unable to join node to cluster: %w" , err )
297
295
metrics .ReportJoinFailed (c .Context , jcmd .InstallationSpec .MetricsBaseURL , jcmd .ClusterID , err )
298
296
return err
@@ -340,10 +338,10 @@ var joinCommand = &cli.Command{
340
338
},
341
339
}
342
340
343
- func applyNetworkConfiguration (jcmd * JoinCommandResponse , networkInterface string ) error {
341
+ func applyNetworkConfiguration (c * cli. Context , jcmd * JoinCommandResponse ) error {
344
342
if jcmd .InstallationSpec .Network != nil {
345
343
clusterSpec := config .RenderK0sConfig ()
346
- address , err := netutils .FirstValidAddress (networkInterface )
344
+ address , err := netutils .FirstValidAddress (c . String ( "network-interface" ) )
347
345
if err != nil {
348
346
return fmt .Errorf ("unable to find first valid address: %w" , err )
349
347
}
@@ -488,14 +486,14 @@ func systemdUnitFileName() string {
488
486
489
487
// runK0sInstallCommand runs the k0s install command as provided by the kots
490
488
// adm api.
491
- func runK0sInstallCommand (fullcmd string , networkInterface string ) error {
489
+ func runK0sInstallCommand (c * cli. Context , fullcmd string ) error {
492
490
args := strings .Split (fullcmd , " " )
493
491
args = append (args , "--token-file" , "/etc/k0s/join-token" )
494
492
if strings .Contains (fullcmd , "controller" ) {
495
493
args = append (args , "--disable-components" , "konnectivity-server" , "--enable-dynamic-config" )
496
494
}
497
495
498
- nodeIP , err := netutils .FirstValidAddress (networkInterface )
496
+ nodeIP , err := netutils .FirstValidAddress (c . String ( "network-interface" ) )
499
497
if err != nil {
500
498
return fmt .Errorf ("unable to find first valid address: %w" , err )
501
499
}
0 commit comments