Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#905 from wzshiming/clean/component…
Browse files Browse the repository at this point in the history
…-patch

Clean up components patches
  • Loading branch information
wzshiming authored Jan 8, 2024
2 parents d4ff83a + 8f642b7 commit 55fc442
Show file tree
Hide file tree
Showing 21 changed files with 274 additions and 363 deletions.
29 changes: 12 additions & 17 deletions pkg/kwokctl/components/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,17 @@ import (

// BuildEtcdComponentConfig is the configuration for building an etcd component.
type BuildEtcdComponentConfig struct {
Runtime string
Binary string
Image string
ProjectName string
Version version.Version
DataPath string
Workdir string
BindAddress string
Port uint32
PeerPort uint32
Verbosity log.Level
ExtraArgs []internalversion.ExtraArgs
ExtraVolumes []internalversion.Volume
ExtraEnvs []internalversion.Env
Runtime string
Binary string
Image string
ProjectName string
Version version.Version
DataPath string
Workdir string
BindAddress string
Port uint32
PeerPort uint32
Verbosity log.Level
}

// BuildEtcdComponent builds an etcd component.
Expand All @@ -59,15 +56,14 @@ func BuildEtcdComponent(conf BuildEtcdComponentConfig) (component internalversio
}

var volumes []internalversion.Volume
volumes = append(volumes, conf.ExtraVolumes...)
var ports []internalversion.Port

etcdArgs := []string{
"--name=node0",
"--auto-compaction-retention=1",
"--quota-backend-bytes=8589934592",
}
etcdArgs = append(etcdArgs, extraArgsToStrings(conf.ExtraArgs)...)

var metric *internalversion.ComponentMetric

if GetRuntimeMode(conf.Runtime) != RuntimeModeNative {
Expand Down Expand Up @@ -149,7 +145,6 @@ func BuildEtcdComponent(conf BuildEtcdComponentConfig) (component internalversio
Value: runtime.GOARCH,
})
}
envs = append(envs, conf.ExtraEnvs...)

return internalversion.Component{
Name: consts.ComponentEtcd,
Expand Down
4 changes: 0 additions & 4 deletions pkg/kwokctl/components/jaeger.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@ type BuildJaegerComponentConfig struct {
Port uint32
OtlpGrpcPort uint32
Verbosity log.Level
ExtraArgs []internalversion.ExtraArgs
ExtraVolumes []internalversion.Volume
}

// BuildJaegerComponent builds a jaeger component.
func BuildJaegerComponent(conf BuildJaegerComponentConfig) (component internalversion.Component, err error) {
jaegerArgs := []string{"--collector.otlp.enabled=true"}
jaegerArgs = append(jaegerArgs, extraArgsToStrings(conf.ExtraArgs)...)

var volumes []internalversion.Volume
volumes = append(volumes, conf.ExtraVolumes...)
var ports []internalversion.Port

if GetRuntimeMode(conf.Runtime) != RuntimeModeNative {
Expand Down
6 changes: 0 additions & 6 deletions pkg/kwokctl/components/kube_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ type BuildKubeApiserverComponentConfig struct {
Verbosity log.Level
DisableQPSLimits bool
TracingConfigPath string
ExtraArgs []internalversion.ExtraArgs
ExtraVolumes []internalversion.Volume
ExtraEnvs []internalversion.Env
}

// BuildKubeApiserverComponent builds a kube-apiserver component.
Expand All @@ -80,7 +77,6 @@ func BuildKubeApiserverComponent(conf BuildKubeApiserverComponentConfig) (compon
)
}

kubeApiserverArgs = append(kubeApiserverArgs, extraArgsToStrings(conf.ExtraArgs)...)
if conf.KubeRuntimeConfig != "" {
kubeApiserverArgs = append(kubeApiserverArgs,
"--runtime-config="+conf.KubeRuntimeConfig,
Expand Down Expand Up @@ -122,7 +118,6 @@ func BuildKubeApiserverComponent(conf BuildKubeApiserverComponentConfig) (compon

var ports []internalversion.Port
var volumes []internalversion.Volume
volumes = append(volumes, conf.ExtraVolumes...)
var metric *internalversion.ComponentMetric

if GetRuntimeMode(conf.Runtime) != RuntimeModeNative {
Expand Down Expand Up @@ -285,7 +280,6 @@ func BuildKubeApiserverComponent(conf BuildKubeApiserverComponentConfig) (compon
}

envs := []internalversion.Env{}
envs = append(envs, conf.ExtraEnvs...)

links := []string{consts.ComponentEtcd}
if conf.TracingConfigPath != "" {
Expand Down
6 changes: 0 additions & 6 deletions pkg/kwokctl/components/kube_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,11 @@ type BuildKubeControllerManagerComponentConfig struct {
NodeMonitorGracePeriodMilliseconds int64
Verbosity log.Level
DisableQPSLimits bool
ExtraArgs []internalversion.ExtraArgs
ExtraVolumes []internalversion.Volume
ExtraEnvs []internalversion.Env
}

// BuildKubeControllerManagerComponent builds a kube-controller-manager component.
func BuildKubeControllerManagerComponent(conf BuildKubeControllerManagerComponentConfig) (component internalversion.Component, err error) {
kubeControllerManagerArgs := []string{}
kubeControllerManagerArgs = append(kubeControllerManagerArgs, extraArgsToStrings(conf.ExtraArgs)...)

if conf.KubeFeatureGates != "" {
kubeControllerManagerArgs = append(kubeControllerManagerArgs,
Expand All @@ -77,7 +73,6 @@ func BuildKubeControllerManagerComponent(conf BuildKubeControllerManagerComponen
}

var volumes []internalversion.Volume
volumes = append(volumes, conf.ExtraVolumes...)
var ports []internalversion.Port
var metric *internalversion.ComponentMetric

Expand Down Expand Up @@ -224,7 +219,6 @@ func BuildKubeControllerManagerComponent(conf BuildKubeControllerManagerComponen
}

envs := []internalversion.Env{}
envs = append(envs, conf.ExtraEnvs...)

return internalversion.Component{
Name: consts.ComponentKubeControllerManager,
Expand Down
6 changes: 0 additions & 6 deletions pkg/kwokctl/components/kube_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ type BuildKubeSchedulerComponentConfig struct {
KubeFeatureGates string
Verbosity log.Level
DisableQPSLimits bool
ExtraArgs []internalversion.ExtraArgs
ExtraVolumes []internalversion.Volume
ExtraEnvs []internalversion.Env
}

// BuildKubeSchedulerComponent builds a kube-scheduler component.
func BuildKubeSchedulerComponent(conf BuildKubeSchedulerComponentConfig) (component internalversion.Component, err error) {
kubeSchedulerArgs := []string{}
kubeSchedulerArgs = append(kubeSchedulerArgs, extraArgsToStrings(conf.ExtraArgs)...)

if conf.KubeFeatureGates != "" {
kubeSchedulerArgs = append(kubeSchedulerArgs,
Expand All @@ -61,7 +57,6 @@ func BuildKubeSchedulerComponent(conf BuildKubeSchedulerComponentConfig) (compon
}

var volumes []internalversion.Volume
volumes = append(volumes, conf.ExtraVolumes...)
var ports []internalversion.Port
var metric *internalversion.ComponentMetric

Expand Down Expand Up @@ -214,7 +209,6 @@ func BuildKubeSchedulerComponent(conf BuildKubeSchedulerComponentConfig) (compon
}

envs := []internalversion.Env{}
envs = append(envs, conf.ExtraEnvs...)

return internalversion.Component{
Name: consts.ComponentKubeScheduler,
Expand Down
7 changes: 0 additions & 7 deletions pkg/kwokctl/components/kwok_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ type BuildKwokControllerComponentConfig struct {
Verbosity log.Level
NodeLeaseDurationSeconds uint
EnableCRDs []string
ExtraArgs []internalversion.ExtraArgs
ExtraVolumes []internalversion.Volume
ExtraEnvs []internalversion.Env
}

// BuildKwokControllerComponent builds a kwok controller component.
Expand All @@ -67,10 +64,7 @@ func BuildKwokControllerComponent(conf BuildKwokControllerComponentConfig) (comp
)
}

kwokControllerArgs = append(kwokControllerArgs, extraArgsToStrings(conf.ExtraArgs)...)

var volumes []internalversion.Volume
volumes = append(volumes, conf.ExtraVolumes...)
var ports []internalversion.Port

if GetRuntimeMode(conf.Runtime) != RuntimeModeNative {
Expand Down Expand Up @@ -170,7 +164,6 @@ func BuildKwokControllerComponent(conf BuildKwokControllerComponentConfig) (comp
}

envs := []internalversion.Env{}
envs = append(envs, conf.ExtraEnvs...)

return internalversion.Component{
Name: consts.ComponentKwokController,
Expand Down
6 changes: 0 additions & 6 deletions pkg/kwokctl/components/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,13 @@ type BuildPrometheusComponentConfig struct {
AdminCertPath string
AdminKeyPath string
Verbosity log.Level
ExtraArgs []internalversion.ExtraArgs
ExtraVolumes []internalversion.Volume
ExtraEnvs []internalversion.Env
}

// BuildPrometheusComponent builds a prometheus component.
func BuildPrometheusComponent(conf BuildPrometheusComponentConfig) (component internalversion.Component, err error) {
prometheusArgs := []string{}
prometheusArgs = append(prometheusArgs, extraArgsToStrings(conf.ExtraArgs)...)

var volumes []internalversion.Volume
volumes = append(volumes, conf.ExtraVolumes...)
var ports []internalversion.Port
var metric *internalversion.ComponentMetric

Expand Down Expand Up @@ -99,7 +94,6 @@ func BuildPrometheusComponent(conf BuildPrometheusComponentConfig) (component in
}

envs := []internalversion.Env{}
envs = append(envs, conf.ExtraEnvs...)

return internalversion.Component{
Name: consts.ComponentPrometheus,
Expand Down
6 changes: 0 additions & 6 deletions pkg/kwokctl/components/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ func GroupByLinks(components []internalversion.Component) ([][]internalversion.C
return groups, nil
}

func extraArgsToStrings(args []internalversion.ExtraArgs) []string {
return slices.Map(args, func(arg internalversion.ExtraArgs) string {
return fmt.Sprintf("--%s=%s", arg.Key, arg.Value)
})
}

// The following runtime mode is classification of runtime for components.
const (
RuntimeModeNative = "native"
Expand Down
Loading

0 comments on commit 55fc442

Please sign in to comment.