@@ -10,6 +10,7 @@ import (
10
10
11
11
"github.com/AlecAivazis/survey/v2/terminal"
12
12
k0sconfig "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
13
+ "github.com/replicatedhq/embedded-cluster/cmd/installer/goods"
13
14
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
14
15
"github.com/replicatedhq/embedded-cluster/kinds/types/join"
15
16
"github.com/replicatedhq/embedded-cluster/pkg/addons"
@@ -27,6 +28,7 @@ import (
27
28
"github.com/replicatedhq/embedded-cluster/pkg/release"
28
29
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
29
30
"github.com/replicatedhq/embedded-cluster/pkg/spinner"
31
+ "github.com/replicatedhq/embedded-cluster/pkg/support"
30
32
"github.com/replicatedhq/embedded-cluster/pkg/versions"
31
33
"github.com/sirupsen/logrus"
32
34
"github.com/spf13/cobra"
@@ -36,8 +38,6 @@ import (
36
38
)
37
39
38
40
type JoinCmdFlags struct {
39
- airgapBundle string
40
- isAirgap bool
41
41
noHA bool
42
42
networkInterface string
43
43
assumeYes bool
@@ -60,8 +60,6 @@ func JoinCmd(ctx context.Context, name string) *cobra.Command {
60
60
return err
61
61
}
62
62
63
- flags .isAirgap = flags .airgapBundle != ""
64
-
65
63
return nil
66
64
},
67
65
PostRun : func (cmd * cobra.Command , args []string ) {
@@ -84,7 +82,7 @@ func JoinCmd(ctx context.Context, name string) *cobra.Command {
84
82
metricsReporter .ReportSignalAborted (ctx , sig )
85
83
})
86
84
87
- if err := runJoin (cmd .Context (), name , flags , jcmd , metricsReporter ); err != nil {
85
+ if err := runJoin (cmd .Context (), name , flags , jcmd , args [ 0 ], metricsReporter ); err != nil {
88
86
// Check if this is an interrupt error from the terminal
89
87
if errors .Is (err , terminal .InterruptErr ) {
90
88
metricsReporter .ReportSignalAborted (ctx , syscall .SIGINT )
@@ -114,8 +112,6 @@ func preRunJoin(flags *JoinCmdFlags) error {
114
112
return fmt .Errorf ("join command must be run as root" )
115
113
}
116
114
117
- flags .isAirgap = flags .airgapBundle != ""
118
-
119
115
// if a network interface flag was not provided, attempt to discover it
120
116
if flags .networkInterface == "" {
121
117
autoInterface , err := determineBestNetworkInterface ()
@@ -128,7 +124,11 @@ func preRunJoin(flags *JoinCmdFlags) error {
128
124
}
129
125
130
126
func addJoinFlags (cmd * cobra.Command , flags * JoinCmdFlags ) error {
131
- cmd .Flags ().StringVar (& flags .airgapBundle , "airgap-bundle" , "" , "Path to the air gap bundle. If set, the installation will complete without internet access." )
127
+ cmd .Flags ().String ("airgap-bundle" , "" , "Path to the air gap bundle. If set, the installation will complete without internet access." )
128
+ if err := cmd .Flags ().MarkDeprecated ("airgap-bundle" , "This flag is deprecated (ignored) and will be removed in a future version. The cluster will automatically determine if it's in airgap mode and fetch the necessary artifacts from other nodes." ); err != nil {
129
+ return err
130
+ }
131
+
132
132
cmd .Flags ().StringVar (& flags .networkInterface , "network-interface" , "" , "The network interface to use for the cluster" )
133
133
cmd .Flags ().BoolVar (& flags .ignoreHostPreflights , "ignore-host-preflights" , false , "Run host preflight checks, but prompt the user to continue if they fail instead of exiting." )
134
134
cmd .Flags ().BoolVar (& flags .noHA , "no-ha" , false , "Do not prompt for or enable high availability." )
@@ -147,7 +147,7 @@ func addJoinFlags(cmd *cobra.Command, flags *JoinCmdFlags) error {
147
147
return nil
148
148
}
149
149
150
- func runJoin (ctx context.Context , name string , flags JoinCmdFlags , jcmd * join.JoinCommandResponse , metricsReporter preflights.MetricsReporter ) error {
150
+ func runJoin (ctx context.Context , name string , flags JoinCmdFlags , jcmd * join.JoinCommandResponse , kotsAPIAddress string , metricsReporter preflights.MetricsReporter ) error {
151
151
// both controller and worker nodes will have 'worker' in the join command
152
152
isWorker := ! strings .Contains (jcmd .K0sJoinCommand , "controller" )
153
153
if ! isWorker {
@@ -158,7 +158,7 @@ func runJoin(ctx context.Context, name string, flags JoinCmdFlags, jcmd *join.Jo
158
158
return err
159
159
}
160
160
161
- cidrCfg , err := initializeJoin (ctx , name , flags , jcmd )
161
+ cidrCfg , err := initializeJoin (ctx , name , jcmd , kotsAPIAddress )
162
162
if err != nil {
163
163
return fmt .Errorf ("unable to initialize join: %w" , err )
164
164
}
@@ -221,18 +221,6 @@ func runJoinVerifyAndPrompt(name string, flags JoinCmdFlags, jcmd *join.JoinComm
221
221
return err
222
222
}
223
223
224
- err = verifyChannelRelease ("join" , flags .isAirgap , flags .assumeYes )
225
- if err != nil {
226
- return err
227
- }
228
-
229
- if flags .isAirgap {
230
- logrus .Debugf ("checking airgap bundle matches binary" )
231
- if err := checkAirgapMatches (flags .airgapBundle ); err != nil {
232
- return err // we want the user to see the error message without a prefix
233
- }
234
- }
235
-
236
224
runtimeconfig .Set (jcmd .InstallationSpec .RuntimeConfig )
237
225
isWorker := ! strings .Contains (jcmd .K0sJoinCommand , "controller" )
238
226
if isWorker {
@@ -282,7 +270,7 @@ func runJoinVerifyAndPrompt(name string, flags JoinCmdFlags, jcmd *join.JoinComm
282
270
return nil
283
271
}
284
272
285
- func initializeJoin (ctx context.Context , name string , flags JoinCmdFlags , jcmd * join.JoinCommandResponse ) (cidrCfg * CIDRConfig , err error ) {
273
+ func initializeJoin (ctx context.Context , name string , jcmd * join.JoinCommandResponse , kotsAPIAddress string ) (cidrCfg * CIDRConfig , err error ) {
286
274
logrus .Info ("" )
287
275
spinner := spinner .Start ()
288
276
spinner .Infof ("Initializing" )
@@ -305,8 +293,8 @@ func initializeJoin(ctx context.Context, name string, flags JoinCmdFlags, jcmd *
305
293
}
306
294
307
295
logrus .Debugf ("materializing %s binaries" , name )
308
- if err := materializeFiles ( flags . airgapBundle ); err != nil {
309
- return nil , err
296
+ if err := materializeFilesForJoin ( ctx , jcmd , kotsAPIAddress ); err != nil {
297
+ return nil , fmt . Errorf ( "failed to materialize files: %w" , err )
310
298
}
311
299
312
300
logrus .Debugf ("configuring sysctl" )
@@ -337,6 +325,24 @@ func initializeJoin(ctx context.Context, name string, flags JoinCmdFlags, jcmd *
337
325
return cidrCfg , nil
338
326
}
339
327
328
+ func materializeFilesForJoin (ctx context.Context , jcmd * join.JoinCommandResponse , kotsAPIAddress string ) error {
329
+ materializer := goods .NewMaterializer ()
330
+ if err := materializer .Materialize (); err != nil {
331
+ return fmt .Errorf ("materialize binaries: %w" , err )
332
+ }
333
+ if err := support .MaterializeSupportBundleSpec (); err != nil {
334
+ return fmt .Errorf ("materialize support bundle spec: %w" , err )
335
+ }
336
+
337
+ if jcmd .InstallationSpec .AirGap {
338
+ if err := airgap .FetchAndWriteArtifacts (ctx , kotsAPIAddress ); err != nil {
339
+ return fmt .Errorf ("failed to fetch artifacts: %w" , err )
340
+ }
341
+ }
342
+
343
+ return nil
344
+ }
345
+
340
346
func getJoinCIDRConfig (jcmd * join.JoinCommandResponse ) (* CIDRConfig , error ) {
341
347
podCIDR , serviceCIDR , err := netutils .SplitNetworkCIDR (ecv1beta1 .DefaultNetworkCIDR )
342
348
if err != nil {
@@ -400,7 +406,7 @@ func installAndJoinCluster(ctx context.Context, jcmd *join.JoinCommandResponse,
400
406
return fmt .Errorf ("unable to join node to cluster: %w" , err )
401
407
}
402
408
403
- if err := startAndWaitForK0s (ctx , name , jcmd ); err != nil {
409
+ if err := startAndWaitForK0s (name ); err != nil {
404
410
return err
405
411
}
406
412
@@ -464,7 +470,7 @@ func applyNetworkConfiguration(networkInterface string, jcmd *join.JoinCommandRe
464
470
}
465
471
466
472
// startAndWaitForK0s starts the k0s service and waits for the node to be ready.
467
- func startAndWaitForK0s (ctx context. Context , name string , jcmd * join. JoinCommandResponse ) error {
473
+ func startAndWaitForK0s (name string ) error {
468
474
logrus .Debugf ("starting %s service" , name )
469
475
if _ , err := helpers .RunCommand (runtimeconfig .K0sBinaryPath (), "start" ); err != nil {
470
476
return fmt .Errorf ("unable to start service: %w" , err )
@@ -600,7 +606,7 @@ func maybeEnableHA(ctx context.Context, kcli client.Client, flags JoinCmdFlags,
600
606
}
601
607
602
608
airgapChartsPath := ""
603
- if flags . isAirgap {
609
+ if jcmd . InstallationSpec . AirGap {
604
610
airgapChartsPath = runtimeconfig .EmbeddedClusterChartsSubDir ()
605
611
}
606
612
hcli , err := helm .NewClient (helm.HelmOptions {
0 commit comments