From ebdd6f4b475075c37d79a40753e98fddb409b6f7 Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Wed, 15 Jan 2025 17:40:18 +0100 Subject: [PATCH] Decouple controller flags from CLIOptions struct This eliminates one more global variable. Make the single and enable-worker flags an implementation detail of flag handling, and provide an enum to the outside world instead. Draw a clear line between controller and worker flags. Instead of accessing the entire controller flags struct in the worker, have a bespoke interface that acts as an integration point between a worker and its embedding controller, if any. Signed-off-by: Tom Wieczorek --- cmd/controller/controller.go | 99 +++++++++++++++------------ cmd/install/controller.go | 3 +- cmd/worker/worker.go | 15 ++-- cmd/worker/worker_other.go | 2 +- cmd/worker/worker_unix.go | 4 +- pkg/component/controller/autopilot.go | 4 +- pkg/config/cli.go | 61 +++++++++++------ 7 files changed, 112 insertions(+), 76 deletions(-) diff --git a/cmd/controller/controller.go b/cmd/controller/controller.go index 9036d803c085..4b2dc9ff61fe 100644 --- a/cmd/controller/controller.go +++ b/cmd/controller/controller.go @@ -70,7 +70,10 @@ import ( type command config.CLIOptions func NewControllerCmd() *cobra.Command { - var ignorePreFlightChecks bool + var ( + controllerFlags config.ControllerOptions + ignorePreFlightChecks bool + ) cmd := &cobra.Command{ Use: "controller [join-token]", @@ -103,13 +106,13 @@ func NewControllerCmd() *cobra.Command { if c.TokenArg != "" && c.TokenFile != "" { return errors.New("you can only pass one token argument either as a CLI argument 'k0s controller [join-token]' or as a flag 'k0s controller --token-file [path]'") } - if err := c.ControllerOptions.Normalize(); err != nil { + if err := controllerFlags.Normalize(); err != nil { return err } if err := (&sysinfo.K0sSysinfoSpec{ ControllerRoleEnabled: true, - WorkerRoleEnabled: c.SingleNode || c.EnableWorker, + WorkerRoleEnabled: controllerFlags.Mode().WorkloadsEnabled(), DataDir: c.K0sVars.DataDir, }).RunPreFlightChecks(ignorePreFlightChecks); !ignorePreFlightChecks && err != nil { return err @@ -117,20 +120,21 @@ func NewControllerCmd() *cobra.Command { ctx, cancel := signal.NotifyContext(cmd.Context(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM) defer cancel() - return c.start(ctx) + return c.start(ctx, &controllerFlags) }, } flags := cmd.Flags() flags.AddFlagSet(config.GetPersistentFlagSet()) - flags.AddFlagSet(config.GetControllerFlags()) + flags.AddFlagSet(config.GetControllerFlags(&controllerFlags)) flags.AddFlagSet(config.GetWorkerFlags()) + flags.AddFlagSet(config.FileInputFlag()) flags.BoolVar(&ignorePreFlightChecks, "ignore-pre-flight-checks", false, "continue even if pre-flight checks fail") return cmd } -func (c *command) start(ctx context.Context) error { +func (c *command) start(ctx context.Context, flags *config.ControllerOptions) error { perfTimer := performance.NewTimer("controller-start").Buffer().Start() nodeConfig, err := c.K0sVars.NodeConfig() @@ -240,6 +244,8 @@ func (c *command) start(ctx context.Context) error { logrus.Infof("using storage backend %s", nodeConfig.Spec.Storage.Type) nodeComponents.Add(ctx, storageBackend) + controllerMode := flags.Mode() + // Assume a single active controller during startup numActiveControllers := value.NewLatest[uint](1) @@ -249,10 +255,10 @@ func (c *command) start(ctx context.Context) error { }) enableK0sEndpointReconciler := nodeConfig.Spec.API.ExternalAddress != "" && - !slices.Contains(c.DisableComponents, constant.APIEndpointReconcilerComponentName) + !slices.Contains(flags.DisableComponents, constant.APIEndpointReconcilerComponentName) if cplbCfg := nodeConfig.Spec.Network.ControlPlaneLoadBalancing; cplbCfg != nil && cplbCfg.Enabled { - if c.SingleNode { + if controllerMode == config.SingleNodeMode { return errors.New("control plane load balancing cannot be used in a single-node cluster") } @@ -271,7 +277,7 @@ func (c *command) start(ctx context.Context) error { }) } - enableKonnectivity := !c.SingleNode && !slices.Contains(c.DisableComponents, constant.KonnectivityServerComponentName) + enableKonnectivity := controllerMode != config.SingleNodeMode && !slices.Contains(flags.DisableComponents, constant.KonnectivityServerComponentName) if enableKonnectivity { nodeComponents.Add(ctx, &controller.Konnectivity{ @@ -293,7 +299,7 @@ func (c *command) start(ctx context.Context) error { DisableEndpointReconciler: enableK0sEndpointReconciler, }) - if !c.SingleNode { + if controllerMode != config.SingleNodeMode { nodeComponents.Add(ctx, &controller.K0sControllersLeaseCounter{ InvocationID: c.K0sVars.InvocationID, ClusterConfig: nodeConfig, @@ -308,7 +314,7 @@ func (c *command) start(ctx context.Context) error { } // One leader elector per controller - if !c.SingleNode { + if controllerMode != config.SingleNodeMode { // The name used to be hardcoded in the component itself // At some point we need to rename this. leaderElector = leaderelector.NewLeasePool(c.K0sVars.InvocationID, adminClientFactory, "k0s-endpoint-reconciler") @@ -317,7 +323,7 @@ func (c *command) start(ctx context.Context) error { } nodeComponents.Add(ctx, leaderElector) - if !slices.Contains(c.DisableComponents, constant.ApplierManagerComponentName) { + if !slices.Contains(flags.DisableComponents, constant.ApplierManagerComponentName) { nodeComponents.Add(ctx, &applier.Manager{ K0sVars: c.K0sVars, KubeClientFactory: adminClientFactory, @@ -328,26 +334,26 @@ func (c *command) start(ctx context.Context) error { }) } - if !c.SingleNode && !slices.Contains(c.DisableComponents, constant.ControlAPIComponentName) { + if controllerMode != config.SingleNodeMode && !slices.Contains(flags.DisableComponents, constant.ControlAPIComponentName) { nodeComponents.Add(ctx, &controller.K0SControlAPI{ ConfigPath: c.CfgFile, K0sVars: c.K0sVars, }) } - if !slices.Contains(c.DisableComponents, constant.CsrApproverComponentName) { + if !slices.Contains(flags.DisableComponents, constant.CsrApproverComponentName) { nodeComponents.Add(ctx, controller.NewCSRApprover(nodeConfig, leaderElector, adminClientFactory)) } - if c.EnableK0sCloudProvider { + if flags.EnableK0sCloudProvider { nodeComponents.Add( ctx, controller.NewK0sCloudProvider( c.K0sVars.AdminKubeConfigPath, - c.K0sCloudProviderUpdateFrequency, - c.K0sCloudProviderPort, + flags.K0sCloudProviderUpdateFrequency, + flags.K0sCloudProviderPort, ), ) } @@ -358,8 +364,8 @@ func (c *command) start(ctx context.Context) error { Role: "controller", Args: os.Args, Version: build.Version, - Workloads: c.SingleNode || c.EnableWorker, - SingleNode: c.SingleNode, + Workloads: controllerMode.WorkloadsEnabled(), + SingleNode: controllerMode == config.SingleNodeMode, K0sVars: c.K0sVars, ClusterConfig: nodeConfig, }, @@ -416,7 +422,7 @@ func (c *command) start(ctx context.Context) error { var configSource clusterconfig.ConfigSource // For backwards compatibility, use file as config source by default - if c.EnableDynamicConfig { + if flags.EnableDynamicConfig { clusterComponents.Add(ctx, controller.NewClusterConfigInitializer( adminClientFactory, leaderElector, @@ -437,7 +443,7 @@ func (c *command) start(ctx context.Context) error { configSource, )) - if !slices.Contains(c.DisableComponents, constant.HelmComponentName) { + if !slices.Contains(flags.DisableComponents, constant.HelmComponentName) { helmSaver, err := controller.NewManifestsSaver("helm", c.K0sVars.DataDir) if err != nil { return fmt.Errorf("failed to initialize helm manifests saver: %w", err) @@ -450,7 +456,7 @@ func (c *command) start(ctx context.Context) error { )) } - if !slices.Contains(c.DisableComponents, constant.AutopilotComponentName) { + if !slices.Contains(flags.DisableComponents, constant.AutopilotComponentName) { logrus.Debug("starting manifest saver") manifestsSaver, err := controller.NewManifestsSaver("autopilot", c.K0sVars.DataDir) if err != nil { @@ -469,11 +475,11 @@ func (c *command) start(ctx context.Context) error { )) } - if !slices.Contains(c.DisableComponents, constant.KubeProxyComponentName) { + if !slices.Contains(flags.DisableComponents, constant.KubeProxyComponentName) { clusterComponents.Add(ctx, controller.NewKubeProxy(c.K0sVars, nodeConfig)) } - if !slices.Contains(c.DisableComponents, constant.CoreDNSComponentname) { + if !slices.Contains(flags.DisableComponents, constant.CoreDNSComponentname) { coreDNS, err := controller.NewCoreDNS(c.K0sVars, adminClientFactory, nodeConfig) if err != nil { return fmt.Errorf("failed to create CoreDNS reconciler: %w", err) @@ -481,7 +487,7 @@ func (c *command) start(ctx context.Context) error { clusterComponents.Add(ctx, coreDNS) } - if !slices.Contains(c.DisableComponents, constant.NetworkProviderComponentName) { + if !slices.Contains(flags.DisableComponents, constant.NetworkProviderComponentName) { logrus.Infof("Creating network reconcilers") calicoSaver, err := controller.NewManifestsSaver("calico", c.K0sVars.DataDir) @@ -497,7 +503,7 @@ func (c *command) start(ctx context.Context) error { return fmt.Errorf("failed to create windows manifests saver: %w", err) } clusterComponents.Add(ctx, controller.NewCalico(c.K0sVars, calicoInitSaver, calicoSaver)) - if !slices.Contains(c.DisableComponents, constant.WindowsNodeComponentName) { + if !slices.Contains(flags.DisableComponents, constant.WindowsNodeComponentName) { clusterComponents.Add(ctx, controller.NewWindowsStackComponent(c.K0sVars, adminClientFactory, windowsStackSaver)) } kubeRouterSaver, err := controller.NewManifestsSaver("kuberouter", c.K0sVars.DataDir) @@ -507,11 +513,11 @@ func (c *command) start(ctx context.Context) error { clusterComponents.Add(ctx, controller.NewKubeRouter(c.K0sVars, kubeRouterSaver)) } - if !slices.Contains(c.DisableComponents, constant.MetricsServerComponentName) { + if !slices.Contains(flags.DisableComponents, constant.MetricsServerComponentName) { clusterComponents.Add(ctx, controller.NewMetricServer(c.K0sVars, adminClientFactory)) } - if c.EnableMetricsScraper { + if flags.EnableMetricsScraper { metricsSaver, err := controller.NewManifestsSaver("metrics", c.K0sVars.DataDir) if err != nil { return fmt.Errorf("failed to create metrics manifests saver: %w", err) @@ -523,7 +529,7 @@ func (c *command) start(ctx context.Context) error { clusterComponents.Add(ctx, metrics) } - if !slices.Contains(c.DisableComponents, constant.WorkerConfigComponentName) { + if !slices.Contains(flags.DisableComponents, constant.WorkerConfigComponentName) { // Create new dedicated leasepool for worker config reconciler leaseName := fmt.Sprintf("k0s-%s-%s", constant.WorkerConfigComponentName, constant.KubernetesMajorMinorVersion) workerConfigLeasePool := leaderelector.NewLeasePool(c.K0sVars.InvocationID, adminClientFactory, leaseName) @@ -536,11 +542,11 @@ func (c *command) start(ctx context.Context) error { clusterComponents.Add(ctx, reconciler) } - if !slices.Contains(c.DisableComponents, constant.SystemRbacComponentName) { + if !slices.Contains(flags.DisableComponents, constant.SystemRbacComponentName) { clusterComponents.Add(ctx, controller.NewSystemRBAC(c.K0sVars.ManifestsDir)) } - if !slices.Contains(c.DisableComponents, constant.NodeRoleComponentName) { + if !slices.Contains(flags.DisableComponents, constant.NodeRoleComponentName) { clusterComponents.Add(ctx, controller.NewNodeRole(c.K0sVars, adminClientFactory)) } @@ -553,21 +559,21 @@ func (c *command) start(ctx context.Context) error { }) } - if !slices.Contains(c.DisableComponents, constant.KubeSchedulerComponentName) { + if !slices.Contains(flags.DisableComponents, constant.KubeSchedulerComponentName) { clusterComponents.Add(ctx, &controller.Scheduler{ LogLevel: c.LogLevels.KubeScheduler, K0sVars: c.K0sVars, - SingleNode: c.SingleNode, + SingleNode: controllerMode == config.SingleNodeMode, }) } - if !slices.Contains(c.DisableComponents, constant.KubeControllerManagerComponentName) { + if !slices.Contains(flags.DisableComponents, constant.KubeControllerManagerComponentName) { clusterComponents.Add(ctx, &controller.Manager{ LogLevel: c.LogLevels.KubeControllerManager, K0sVars: c.K0sVars, - SingleNode: c.SingleNode, + SingleNode: controllerMode == config.SingleNodeMode, ServiceClusterIPRange: nodeConfig.Spec.Network.BuildServiceCIDR(nodeConfig.Spec.API.Address), - ExtraArgs: c.KubeControllerManagerExtraArgs, + ExtraArgs: flags.KubeControllerManagerExtraArgs, }) } @@ -585,7 +591,7 @@ func (c *command) start(ctx context.Context) error { K0sVars: c.K0sVars, KubeletExtraArgs: c.KubeletExtraArgs, AdminClientFactory: adminClientFactory, - EnableWorker: c.EnableWorker, + Workloads: controllerMode.WorkloadsEnabled(), }) restConfig, err := adminClientFactory.GetRESTConfig() @@ -623,9 +629,9 @@ func (c *command) start(ctx context.Context) error { } }() - if c.EnableWorker { + if controllerMode.WorkloadsEnabled() { perfTimer.Checkpoint("starting-worker") - if err := c.startWorker(ctx, c.WorkerProfile, nodeConfig); err != nil { + if err := c.startWorker(ctx, flags, nodeConfig); err != nil { logrus.WithError(err).Error("Failed to start controller worker") } else { perfTimer.Checkpoint("started-worker") @@ -644,7 +650,7 @@ func (c *command) start(ctx context.Context) error { return nil } -func (c *command) startWorker(ctx context.Context, profile string, nodeConfig *v1beta1.ClusterConfig) error { +func (c *command) startWorker(ctx context.Context, opts *config.ControllerOptions, nodeConfig *v1beta1.ClusterConfig) error { var bootstrapConfig string if !file.Exists(c.K0sVars.KubeletAuthConfigPath) { // wait for controller to start up @@ -679,15 +685,20 @@ func (c *command) startWorker(ctx context.Context, profile string, nodeConfig *v // possibly other args won't get messed up. wc := workercmd.Command(*(*config.CLIOptions)(c)) wc.TokenArg = bootstrapConfig - wc.WorkerProfile = profile wc.Labels = append(wc.Labels, fields.OneTermEqualSelector(constant.K0SNodeRoleLabel, "control-plane").String()) - wc.DisableIPTables = true - if !c.SingleNode && !c.NoTaints { + if opts.Mode() == config.ControllerPlusWorkerMode && !opts.NoTaints { key := path.Join(constant.NodeRoleLabelNamespace, "master") taint := fields.OneTermEqualSelector(key, ":NoSchedule") wc.Taints = append(wc.Taints, taint.String()) } - return wc.Start(ctx) + return wc.Start(ctx, (*embeddingController)(opts)) +} + +type embeddingController config.ControllerOptions + +// IsSingleNode implements [workercmd.EmbeddingController]. +func (c *embeddingController) IsSingleNode() bool { + return (*config.ControllerOptions)(c).Mode() == config.SingleNodeMode } // If we've got an etcd data directory in place for embedded etcd, or a ca for diff --git a/cmd/install/controller.go b/cmd/install/controller.go index 82e54431b85f..657c83b2666b 100644 --- a/cmd/install/controller.go +++ b/cmd/install/controller.go @@ -84,8 +84,9 @@ With the controller subcommand you can setup a single node cluster by running: flags := cmd.Flags() flags.AddFlagSet(config.GetPersistentFlagSet()) - flags.AddFlagSet(config.GetControllerFlags()) + flags.AddFlagSet(config.GetControllerFlags(&config.ControllerOptions{})) flags.AddFlagSet(config.GetWorkerFlags()) + flags.AddFlagSet(config.FileInputFlag()) return cmd } diff --git a/cmd/worker/worker.go b/cmd/worker/worker.go index 2f1fcea6d771..9a2e8d3d37d6 100644 --- a/cmd/worker/worker.go +++ b/cmd/worker/worker.go @@ -43,6 +43,11 @@ import ( type Command config.CLIOptions +// Interface between an embedded worker and its embedding controller. +type EmbeddingController interface { + IsSingleNode() bool +} + func NewWorkerCmd() *cobra.Command { var ignorePreFlightChecks bool @@ -89,7 +94,7 @@ func NewWorkerCmd() *cobra.Command { ctx, cancel := signal.NotifyContext(cmd.Context(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM) defer cancel() - return c.Start(ctx) + return c.Start(ctx, nil) }, } @@ -102,7 +107,7 @@ func NewWorkerCmd() *cobra.Command { } // Start starts the worker components based on the given [config.CLIOptions]. -func (c *Command) Start(ctx context.Context) error { +func (c *Command) Start(ctx context.Context, controller EmbeddingController) error { if err := worker.BootstrapKubeletKubeconfig(ctx, c.K0sVars, &c.WorkerOptions); err != nil { return err } @@ -123,7 +128,7 @@ func (c *Command) Start(ctx context.Context) error { var staticPods worker.StaticPods if workerConfig.NodeLocalLoadBalancing.IsEnabled() { - if c.SingleNode { + if controller != nil && controller.IsSingleNode() { return errors.New("node-local load balancing cannot be used in a single-node cluster") } @@ -148,7 +153,7 @@ func (c *Command) Start(ctx context.Context) error { c.WorkerProfile = "default-windows" } - if !c.DisableIPTables { + if controller == nil { componentManager.Add(ctx, &iptables.Component{ IPTablesMode: c.WorkerOptions.IPTablesMode, BinDir: c.K0sVars.BinDir, @@ -171,7 +176,7 @@ func (c *Command) Start(ctx context.Context) error { certManager := worker.NewCertificateManager(kubeletKubeconfigPath) - addPlatformSpecificComponents(ctx, componentManager, c.K0sVars, &c.ControllerOptions, certManager) + addPlatformSpecificComponents(ctx, componentManager, c.K0sVars, controller, certManager) // extract needed components if err := componentManager.Init(ctx); err != nil { diff --git a/cmd/worker/worker_other.go b/cmd/worker/worker_other.go index 2f0ef1153dc8..e762b35a4b9b 100644 --- a/cmd/worker/worker_other.go +++ b/cmd/worker/worker_other.go @@ -26,6 +26,6 @@ import ( "github.com/k0sproject/k0s/pkg/config" ) -func addPlatformSpecificComponents(context.Context, *manager.Manager, *config.CfgVars, *config.ControllerOptions, *worker.CertificateManager) { +func addPlatformSpecificComponents(context.Context, *manager.Manager, *config.CfgVars, EmbeddingController, *worker.CertificateManager) { // no-op } diff --git a/cmd/worker/worker_unix.go b/cmd/worker/worker_unix.go index 0f4908f9cd5c..9e70403b1ce7 100644 --- a/cmd/worker/worker_unix.go +++ b/cmd/worker/worker_unix.go @@ -30,9 +30,9 @@ import ( "github.com/k0sproject/k0s/pkg/config" ) -func addPlatformSpecificComponents(ctx context.Context, m *manager.Manager, k0sVars *config.CfgVars, opts *config.ControllerOptions, certManager *worker.CertificateManager) { +func addPlatformSpecificComponents(ctx context.Context, m *manager.Manager, k0sVars *config.CfgVars, controller EmbeddingController, certManager *worker.CertificateManager) { // if running inside a controller, status component is already running - if !opts.SingleNode && !opts.EnableWorker { + if controller != nil { m.Add(ctx, &status.Status{ Prober: prober.DefaultProber, StatusInformation: status.K0sStatus{ diff --git a/pkg/component/controller/autopilot.go b/pkg/component/controller/autopilot.go index 4794393a0865..ff8fe01470ef 100644 --- a/pkg/component/controller/autopilot.go +++ b/pkg/component/controller/autopilot.go @@ -38,7 +38,7 @@ type Autopilot struct { K0sVars *config.CfgVars KubeletExtraArgs string AdminClientFactory kubernetes.ClientFactoryInterface - EnableWorker bool + Workloads bool } func (a *Autopilot) Init(ctx context.Context) error { @@ -66,7 +66,7 @@ func (a *Autopilot) Start(ctx context.Context) error { ManagerPort: 8899, MetricsBindAddr: "0", HealthProbeBindAddr: "0", - }, logrus.WithFields(logrus.Fields{"component": "autopilot"}), a.EnableWorker, a.AdminClientFactory, autopilotClientFactory) + }, logrus.WithFields(logrus.Fields{"component": "autopilot"}), a.Workloads, a.AdminClientFactory, autopilotClientFactory) if err != nil { return fmt.Errorf("failed to create autopilot controller: %w", err) } diff --git a/pkg/config/cli.go b/pkg/config/cli.go index 0dcedda855e6..3617e66829d3 100644 --- a/pkg/config/cli.go +++ b/pkg/config/cli.go @@ -33,20 +33,18 @@ import ( ) var ( - CfgFile string - Debug bool - DebugListenOn string - K0sVars CfgVars - workerOpts WorkerOptions - Verbose bool - controllerOpts ControllerOptions + CfgFile string + Debug bool + DebugListenOn string + K0sVars CfgVars + workerOpts WorkerOptions + Verbose bool ) // This struct holds all the CLI options & settings required by the // different k0s sub-commands type CLIOptions struct { WorkerOptions - ControllerOptions CfgFile string Debug bool DebugListenOn string @@ -54,10 +52,16 @@ type CLIOptions struct { Verbose bool } +type ControllerMode uint8 + +const ( + ControllerOnlyMode ControllerMode = iota + ControllerPlusWorkerMode + SingleNodeMode +) + // Shared controller cli flags type ControllerOptions struct { - EnableWorker bool - SingleNode bool NoTaints bool DisableComponents []string @@ -69,6 +73,8 @@ type ControllerOptions struct { EnableDynamicConfig bool EnableMetricsScraper bool KubeControllerManagerExtraArgs string + + enableWorker, singleNode bool } // Shared worker cli flags @@ -84,7 +90,26 @@ type WorkerOptions struct { TokenArg string WorkerProfile string IPTablesMode string - DisableIPTables bool +} + +func (m ControllerMode) WorkloadsEnabled() bool { + switch m { + case ControllerPlusWorkerMode, SingleNodeMode: + return true + default: + return false + } +} + +func (o *ControllerOptions) Mode() ControllerMode { + switch { + case o.singleNode: + return SingleNodeMode + case o.enableWorker: + return ControllerPlusWorkerMode + default: + return ControllerOnlyMode + } } func (o *ControllerOptions) Normalize() error { @@ -267,12 +292,12 @@ var availableComponents = []string{ constant.WorkerConfigComponentName, } -func GetControllerFlags() *pflag.FlagSet { +func GetControllerFlags(controllerOpts *ControllerOptions) *pflag.FlagSet { flagset := &pflag.FlagSet{} - flagset.BoolVar(&controllerOpts.EnableWorker, "enable-worker", false, "enable worker (default false)") + flagset.BoolVar(&controllerOpts.enableWorker, "enable-worker", false, "enable worker (default false)") flagset.StringSliceVar(&controllerOpts.DisableComponents, "disable-components", []string{}, "disable components (valid items: "+strings.Join(availableComponents, ",")+")") - flagset.BoolVar(&controllerOpts.SingleNode, "single", false, "enable single node (implies --enable-worker, default false)") + flagset.BoolVar(&controllerOpts.singleNode, "single", false, "enable single node (implies --enable-worker, default false)") flagset.BoolVar(&controllerOpts.NoTaints, "no-taints", false, "disable default taints for controller node") flagset.BoolVar(&controllerOpts.EnableK0sCloudProvider, "enable-k0s-cloud-provider", false, "enables the k0s-cloud-provider (default false)") flagset.DurationVar(&controllerOpts.K0sCloudProviderUpdateFrequency, "k0s-cloud-provider-update-frequency", 2*time.Minute, "the frequency of k0s-cloud-provider node updates") @@ -280,7 +305,6 @@ func GetControllerFlags() *pflag.FlagSet { flagset.BoolVar(&controllerOpts.EnableDynamicConfig, "enable-dynamic-config", false, "enable cluster-wide dynamic config based on custom resource") flagset.BoolVar(&controllerOpts.EnableMetricsScraper, "enable-metrics-scraper", false, "enable scraping metrics from the controller components (kube-scheduler, kube-controller-manager)") flagset.StringVar(&controllerOpts.KubeControllerManagerExtraArgs, "kube-controller-manager-extra-args", "", "extra args for kube-controller-manager") - flagset.AddFlagSet(FileInputFlag()) return flagset } @@ -306,13 +330,8 @@ func GetCmdOpts(cobraCmd command) (*CLIOptions, error) { k0sVars = rtc.K0sVars } - if controllerOpts.SingleNode { - controllerOpts.EnableWorker = true - } - return &CLIOptions{ - ControllerOptions: controllerOpts, - WorkerOptions: workerOpts, + WorkerOptions: workerOpts, CfgFile: CfgFile, Debug: Debug,