@@ -144,6 +144,11 @@ var joinCommand = &cli.Command{
144144 Usage : "Enable high availability." ,
145145 Hidden : true ,
146146 },
147+ & cli.StringFlag {
148+ Name : "network-interface" ,
149+ Usage : "The network interface to use for the cluster" ,
150+ Value : "" ,
151+ },
147152 & cli.BoolFlag {
148153 Name : "no-prompt" ,
149154 Usage : "Disable interactive prompts." ,
@@ -181,13 +186,6 @@ var joinCommand = &cli.Command{
181186 return fmt .Errorf ("usage: %s join <url> <token>" , binName )
182187 }
183188
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-
191189 logrus .Debugf ("fetching join token remotely" )
192190 jcmd , err := getJoinToken (c .Context , c .Args ().Get (0 ), c .Args ().Get (1 ))
193191 if err != nil {
@@ -200,7 +198,7 @@ var joinCommand = &cli.Command{
200198 }
201199
202200 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" ) )
204202 if err != nil {
205203 return fmt .Errorf ("failed to check proxy config for local IP: %w" , err )
206204 }
@@ -279,7 +277,7 @@ var joinCommand = &cli.Command{
279277 }
280278
281279 logrus .Debugf ("overriding network configuration" )
282- if err := applyNetworkConfiguration (jcmd , networkInterface ); err != nil {
280+ if err := applyNetworkConfiguration (c , jcmd ); err != nil {
283281 err := fmt .Errorf ("unable to apply network configuration: %w" , err )
284282 metrics .ReportJoinFailed (c .Context , jcmd .InstallationSpec .MetricsBaseURL , jcmd .ClusterID , err )
285283 }
@@ -292,7 +290,7 @@ var joinCommand = &cli.Command{
292290 }
293291
294292 logrus .Debugf ("joining node to cluster" )
295- if err := runK0sInstallCommand (jcmd .K0sJoinCommand , networkInterface ); err != nil {
293+ if err := runK0sInstallCommand (c , jcmd .K0sJoinCommand ); err != nil {
296294 err := fmt .Errorf ("unable to join node to cluster: %w" , err )
297295 metrics .ReportJoinFailed (c .Context , jcmd .InstallationSpec .MetricsBaseURL , jcmd .ClusterID , err )
298296 return err
@@ -340,10 +338,10 @@ var joinCommand = &cli.Command{
340338 },
341339}
342340
343- func applyNetworkConfiguration (jcmd * JoinCommandResponse , networkInterface string ) error {
341+ func applyNetworkConfiguration (c * cli. Context , jcmd * JoinCommandResponse ) error {
344342 if jcmd .InstallationSpec .Network != nil {
345343 clusterSpec := config .RenderK0sConfig ()
346- address , err := netutils .FirstValidAddress (networkInterface )
344+ address , err := netutils .FirstValidAddress (c . String ( "network-interface" ) )
347345 if err != nil {
348346 return fmt .Errorf ("unable to find first valid address: %w" , err )
349347 }
@@ -488,14 +486,14 @@ func systemdUnitFileName() string {
488486
489487// runK0sInstallCommand runs the k0s install command as provided by the kots
490488// adm api.
491- func runK0sInstallCommand (fullcmd string , networkInterface string ) error {
489+ func runK0sInstallCommand (c * cli. Context , fullcmd string ) error {
492490 args := strings .Split (fullcmd , " " )
493491 args = append (args , "--token-file" , "/etc/k0s/join-token" )
494492 if strings .Contains (fullcmd , "controller" ) {
495493 args = append (args , "--disable-components" , "konnectivity-server" , "--enable-dynamic-config" )
496494 }
497495
498- nodeIP , err := netutils .FirstValidAddress (networkInterface )
496+ nodeIP , err := netutils .FirstValidAddress (c . String ( "network-interface" ) )
499497 if err != nil {
500498 return fmt .Errorf ("unable to find first valid address: %w" , err )
501499 }
0 commit comments