Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kwokctl] Generically enable/disable a component #1229

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/apis/config/v1alpha1/kwokctl_configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,30 @@ type KwokctlConfigurationOptions struct {
// is the default value for flag --kube-scheduler-config and env KWOK_KUBE_SCHEDULER_CONFIG
KubeSchedulerConfig string `json:"kubeSchedulerConfig,omitempty"`

// Components is the configuration for components.
Components []string `json:"components,omitempty"`

// Disable is the configuration for disables components.
Disable []string `json:"disable,omitempty"`

// Enable is the configuration for enables components.
Enable []string `json:"enable,omitempty"`

// DisableKubeScheduler is the flag to disable kube-scheduler.
// is the default value for flag --disable-kube-scheduler and env KWOK_DISABLE_KUBE_SCHEDULER
// +default=false
// Deprecated: Use Disable instead
DisableKubeScheduler *bool `json:"disableKubeScheduler,omitempty"`

// DisableKubeControllerManager is the flag to disable kube-controller-manager.
// is the default value for flag --disable-kube-controller-manager and env KWOK_DISABLE_KUBE_CONTROLLER_MANAGER
// +default=false
// Deprecated: Use Disable instead
DisableKubeControllerManager *bool `json:"disableKubeControllerManager,omitempty"`

// EnableMetricsServer is the flag to enable metrics-server.
// +default=false
// Deprecated: Use Enable instead
EnableMetricsServer *bool `json:"enableMetricsServer,omitempty"`

// KubeImagePrefix is the prefix of the kubernetes image.
Expand Down
15 changes: 15 additions & 0 deletions pkg/apis/config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions pkg/apis/internalversion/kwokctl_configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,25 @@ type KwokctlConfigurationOptions struct {
// KubeSchedulerConfig is the configuration path for kube-scheduler.
KubeSchedulerConfig string

// Components is the configuration for components.
Components []string

// Disable is the configuration for disables components.
Disable []string

// Enable is the configuration for enables components.
Enable []string

// DisableKubeScheduler is the flag to disable kube-scheduler.
// Deprecated: Use Disable instead
DisableKubeScheduler bool

// DisableKubeControllerManager is the flag to disable kube-controller-manager.
// Deprecated: Use Disable instead
DisableKubeControllerManager bool

// EnableMetricsServer is the flag to enable metrics-server.
// Deprecated: Use Enable instead
EnableMetricsServer bool

// EtcdImage is the image of etcd.
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/internalversion/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions pkg/apis/internalversion/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions pkg/config/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ func setKwokctlConfigurationDefaults(config *configv1alpha1.KwokctlConfiguration
func setKwokctlKubernetesConfig(conf *configv1alpha1.KwokctlConfigurationOptions) {
conf.DisableKubeScheduler = format.Ptr(envs.GetEnvWithPrefix("DISABLE_KUBE_SCHEDULER", *conf.DisableKubeScheduler))
conf.DisableKubeControllerManager = format.Ptr(envs.GetEnvWithPrefix("DISABLE_KUBE_CONTROLLER_MANAGER", *conf.DisableKubeControllerManager))
if len(conf.Components) == 0 {
conf.Components = []string{
consts.ComponentEtcd,
consts.ComponentKubeApiserver,
consts.ComponentKubeControllerManager,
consts.ComponentKubeScheduler,
consts.ComponentKwokController,
}
}

conf.KubeAuthorization = format.Ptr(envs.GetEnvWithPrefix("KUBE_AUTHORIZATION", *conf.KubeAuthorization))
conf.KubeAdmission = envs.GetEnvWithPrefix("KUBE_ADMISSION", conf.KubeAdmission)
Expand Down
6 changes: 6 additions & 0 deletions pkg/kwokctl/cmd/create/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ func NewCommand(ctx context.Context) *cobra.Command {
cmd.Flags().BoolVar(&flags.Options.SecurePort, "secure-port", flags.Options.SecurePort, `The apiserver port on which to serve HTTPS with authentication and authorization, is not available before Kubernetes 1.13.0`)
cmd.Flags().BoolVar(&flags.Options.QuietPull, "quiet-pull", flags.Options.QuietPull, `Pull without printing progress information`)
cmd.Flags().StringVar(&flags.Options.KubeSchedulerConfig, "kube-scheduler-config", flags.Options.KubeSchedulerConfig, `Path to a kube-scheduler configuration file`)
cmd.Flags().StringSliceVar(&flags.Options.Components, "components", flags.Options.Components, `Default of components`)
cmd.Flags().StringSliceVar(&flags.Options.Disable, "disable", flags.Options.Disable, `Disable list of components`)
cmd.Flags().StringSliceVar(&flags.Options.Enable, "enable", flags.Options.Enable, `Enable list of components`)
cmd.Flags().BoolVar(&flags.Options.DisableKubeScheduler, "disable-kube-scheduler", flags.Options.DisableKubeScheduler, `Disable the kube-scheduler`)
_ = cmd.Flags().MarkDeprecated("disable-kube-scheduler", "--disable-kube-scheduler will be removed in a future release, please use --disable kube-scheduler instead")
cmd.Flags().BoolVar(&flags.Options.DisableKubeControllerManager, "disable-kube-controller-manager", flags.Options.DisableKubeControllerManager, `Disable the kube-controller-manager`)
_ = cmd.Flags().MarkDeprecated("disable-kube-controller-manager", "--disable-kube-controller-manager will be removed in a future release, please use --disable kube-controller-manager instead")
cmd.Flags().BoolVar(&flags.Options.EnableMetricsServer, "enable-metrics-server", flags.Options.EnableMetricsServer, `Enable the metrics-server`)
_ = cmd.Flags().MarkDeprecated("enable-metrics-server", "--enable-metrics-server will be removed in a future release, please use --enable metrics-server instead")
cmd.Flags().StringVar(&flags.Options.EtcdImage, "etcd-image", flags.Options.EtcdImage, `Image of etcd, only for docker/podman/nerdctl runtime
'${KWOK_KUBE_IMAGE_PREFIX}/etcd:${KWOK_ETCD_VERSION}'
`)
Expand Down
Loading
Loading