diff --git a/pkg/kwokctl/components/prometheus.go b/pkg/kwokctl/components/prometheus.go index 93e8093dd7..d383af7704 100644 --- a/pkg/kwokctl/components/prometheus.go +++ b/pkg/kwokctl/components/prometheus.go @@ -27,17 +27,19 @@ import ( // BuildPrometheusComponentConfig is the configuration for building a prometheus component. type BuildPrometheusComponentConfig struct { - Runtime string - Binary string - Image string - Version version.Version - Workdir string - BindAddress string - Port uint32 - ConfigPath string - AdminCertPath string - AdminKeyPath string - Verbosity log.Level + Runtime string + Binary string + Image string + Version version.Version + Workdir string + BindAddress string + Port uint32 + ConfigPath string + AdminCertPath string + AdminKeyPath string + Verbosity log.Level + DisableKubeControllerManager bool + DisableKubeScheduler bool } // BuildPrometheusComponent builds a prometheus component. @@ -107,16 +109,22 @@ func BuildPrometheusComponent(conf BuildPrometheusComponentConfig) (component in envs := []internalversion.Env{} + links := []string{ + consts.ComponentEtcd, + consts.ComponentKubeApiserver, + consts.ComponentKwokController, + } + if !conf.DisableKubeControllerManager { + links = append(links, consts.ComponentKubeControllerManager) + } + if !conf.DisableKubeScheduler { + links = append(links, consts.ComponentKubeScheduler) + } + return internalversion.Component{ Name: consts.ComponentPrometheus, Version: conf.Version.String(), - Links: []string{ - consts.ComponentEtcd, - consts.ComponentKubeApiserver, - consts.ComponentKubeControllerManager, - consts.ComponentKubeScheduler, - consts.ComponentKwokController, - }, + Links: links, Command: []string{consts.ComponentPrometheus}, Ports: ports, Volumes: volumes, diff --git a/pkg/kwokctl/runtime/binary/cluster.go b/pkg/kwokctl/runtime/binary/cluster.go index 88d073adc3..ff44203deb 100644 --- a/pkg/kwokctl/runtime/binary/cluster.go +++ b/pkg/kwokctl/runtime/binary/cluster.go @@ -678,14 +678,16 @@ func (c *Cluster) addPrometheus(ctx context.Context, env *env) (err error) { } prometheusComponent, err := components.BuildPrometheusComponent(components.BuildPrometheusComponentConfig{ - Runtime: conf.Runtime, - Workdir: env.workdir, - Binary: prometheusPath, - Version: prometheusVersion, - BindAddress: conf.BindAddress, - Port: conf.PrometheusPort, - ConfigPath: prometheusConfigPath, - Verbosity: env.verbosity, + Runtime: conf.Runtime, + Workdir: env.workdir, + Binary: prometheusPath, + Version: prometheusVersion, + BindAddress: conf.BindAddress, + Port: conf.PrometheusPort, + ConfigPath: prometheusConfigPath, + Verbosity: env.verbosity, + DisableKubeControllerManager: conf.DisableKubeControllerManager, + DisableKubeScheduler: conf.DisableKubeScheduler, }) if err != nil { return err diff --git a/pkg/kwokctl/runtime/compose/cluster.go b/pkg/kwokctl/runtime/compose/cluster.go index 0c7fd9cfc7..fa265563cd 100644 --- a/pkg/kwokctl/runtime/compose/cluster.go +++ b/pkg/kwokctl/runtime/compose/cluster.go @@ -684,16 +684,18 @@ func (c *Cluster) addPrometheus(ctx context.Context, env *env) (err error) { prometheusConfigPath := c.GetWorkdirPath(runtime.Prometheus) prometheusComponent, err := components.BuildPrometheusComponent(components.BuildPrometheusComponentConfig{ - Runtime: conf.Runtime, - Workdir: env.workdir, - Image: conf.PrometheusImage, - Version: prometheusVersion, - BindAddress: net.PublicAddress, - Port: conf.PrometheusPort, - ConfigPath: prometheusConfigPath, - AdminCertPath: env.adminCertPath, - AdminKeyPath: env.adminKeyPath, - Verbosity: env.verbosity, + Runtime: conf.Runtime, + Workdir: env.workdir, + Image: conf.PrometheusImage, + Version: prometheusVersion, + BindAddress: net.PublicAddress, + Port: conf.PrometheusPort, + ConfigPath: prometheusConfigPath, + AdminCertPath: env.adminCertPath, + AdminKeyPath: env.adminKeyPath, + Verbosity: env.verbosity, + DisableKubeControllerManager: conf.DisableKubeControllerManager, + DisableKubeScheduler: conf.DisableKubeScheduler, }) if err != nil { return err diff --git a/pkg/kwokctl/runtime/kind/cluster.go b/pkg/kwokctl/runtime/kind/cluster.go index e6c3de39c8..13cb10d374 100644 --- a/pkg/kwokctl/runtime/kind/cluster.go +++ b/pkg/kwokctl/runtime/kind/cluster.go @@ -831,16 +831,18 @@ func (c *Cluster) addPrometheus(ctx context.Context, env *env) (err error) { } prometheusComponent, err := components.BuildPrometheusComponent(components.BuildPrometheusComponentConfig{ - Runtime: conf.Runtime, - Workdir: env.workdir, - Image: conf.PrometheusImage, - Version: prometheusVersion, - BindAddress: net.PublicAddress, - Port: 9090, - ConfigPath: "/var/components/prometheus/etc/prometheus/prometheus.yaml", - AdminCertPath: env.adminCertPath, - AdminKeyPath: env.adminKeyPath, - Verbosity: env.verbosity, + Runtime: conf.Runtime, + Workdir: env.workdir, + Image: conf.PrometheusImage, + Version: prometheusVersion, + BindAddress: net.PublicAddress, + Port: 9090, + ConfigPath: "/var/components/prometheus/etc/prometheus/prometheus.yaml", + AdminCertPath: env.adminCertPath, + AdminKeyPath: env.adminKeyPath, + Verbosity: env.verbosity, + DisableKubeControllerManager: conf.DisableKubeControllerManager, + DisableKubeScheduler: conf.DisableKubeScheduler, }) if err != nil { return err