@@ -44,12 +44,7 @@ type Install2CmdFlags struct {
4444
4545 license * kotsv1beta1.License
4646 proxy * ecv1beta1.ProxySpec
47-
48- // cidr flags are deprecated, but these values are still
49- // used. if the --cidr flag is passed, the values will be
50- // calculated
51- podCIDR string
52- serviceCIDR string
47+ cidrCfg * CIDRConfig
5348}
5449
5550// Install2Cmd returns a cobra command for installing the embedded cluster.
@@ -84,12 +79,11 @@ func Install2Cmd(ctx context.Context, name string) *cobra.Command {
8479 }
8580
8681 // parse the various cidr flags to make sure we have exactly what we want
87- pod , svc , err := getPODAndServiceCIDR (cmd )
82+ cidrCfg , err := getCIDRConfig (cmd )
8883 if err != nil {
8984 return fmt .Errorf ("unable to determine pod and service CIDRs: %w" , err )
9085 }
91- flags .podCIDR = pod
92- flags .serviceCIDR = svc
86+ flags .cidrCfg = cidrCfg
9387
9488 // if a network interface flag was not provided, attempt to discover it
9589 if flags .networkInterface == "" {
@@ -179,8 +173,19 @@ func runInstall2(cmd *cobra.Command, args []string, name string, flags Install2C
179173 }
180174
181175 logrus .Debugf ("running host preflights" )
182- if err := runInstallPreflights (cmd .Context (), flags .license , flags .proxy , flags .podCIDR , flags .serviceCIDR ); err != nil {
183- return err
176+ if err := preflights .PrepareAndRun (cmd .Context (), preflights.PrepareAndRunOptions {
177+ License : flags .license ,
178+ Proxy : flags .proxy ,
179+ PodCIDR : flags .cidrCfg .PodCIDR ,
180+ ServiceCIDR : flags .cidrCfg .ServiceCIDR ,
181+ GlobalCIDR : flags .cidrCfg .GlobalCIDR ,
182+ PrivateCAs : flags .privateCAs ,
183+ IsAirgap : flags .airgapBundle != "" ,
184+ SkipHostPreflights : flags .skipHostPreflights ,
185+ IgnoreHostPreflights : flags .ignoreHostPreflights ,
186+ AssumeYes : flags .assumeYes ,
187+ }); err != nil {
188+ return fmt .Errorf ("unable to prepare and run preflights: %w" , err )
184189 }
185190
186191 logrus .Debugf ("configuring sysctl" )
@@ -193,7 +198,7 @@ func runInstall2(cmd *cobra.Command, args []string, name string, flags Install2C
193198 return fmt .Errorf ("unable to configure network manager: %w" , err )
194199 }
195200
196- clusterConfig , err := installAndStartCluster (cmd .Context (), flags .networkInterface , flags .airgapBundle , flags .license , flags .proxy , flags .podCIDR , flags . serviceCIDR , flags .overrides )
201+ clusterConfig , err := installAndStartCluster (cmd .Context (), flags .networkInterface , flags .airgapBundle , flags .license , flags .proxy , flags .cidrCfg , flags .overrides )
197202 if err != nil {
198203 metrics .ReportApplyFinished (cmd .Context (), "" , flags .license , err )
199204 return err
@@ -324,27 +329,13 @@ func runInstallVerifyAndPrompt(ctx context.Context, name string, flags *Install2
324329 return nil
325330}
326331
327- func runInstallPreflights (ctx context.Context , license * kotsv1beta1.License , proxy * ecv1beta1.ProxySpec , podCIDR string , serviceCIDR string ) error {
328- preflightOptions := preflights.PrepareAndRunOptions {
329- License : license ,
330- Proxy : proxy ,
331- ConnectivityFromCIDR : podCIDR ,
332- ConnectivityToCIDR : serviceCIDR ,
333- }
334- if err := preflights .PrepareAndRun (ctx , preflightOptions ); err != nil {
335- return fmt .Errorf ("unable to prepare and run preflights: %w" , err )
336- }
337-
338- return nil
339- }
340-
341- func installAndStartCluster (ctx context.Context , networkInterface string , airgapBundle string , license * kotsv1beta1.License , proxy * ecv1beta1.ProxySpec , podCIDR string , serviceCIDR string , overrides string ) (* k0sconfig.ClusterConfig , error ) {
332+ func installAndStartCluster (ctx context.Context , networkInterface string , airgapBundle string , license * kotsv1beta1.License , proxy * ecv1beta1.ProxySpec , cidrCfg * CIDRConfig , overrides string ) (* k0sconfig.ClusterConfig , error ) {
342333 loading := spinner .Start ()
343334 defer loading .Close ()
344335 loading .Infof ("Installing %s node" , runtimeconfig .BinaryName ())
345336 logrus .Debugf ("creating k0s configuration file" )
346337
347- cfg , err := k0s .WriteK0sConfig (ctx , networkInterface , airgapBundle , podCIDR , serviceCIDR , overrides )
338+ cfg , err := k0s .WriteK0sConfig (ctx , networkInterface , airgapBundle , cidrCfg . PodCIDR , cidrCfg . ServiceCIDR , overrides )
348339 if err != nil {
349340 err := fmt .Errorf ("unable to create config file: %w" , err )
350341 metrics .ReportApplyFinished (ctx , "" , license , err )
0 commit comments