Skip to content

Commit

Permalink
fix broken links dependency for prometheus component
Browse files Browse the repository at this point in the history
  • Loading branch information
chotiwat committed Sep 17, 2024
1 parent dbf1cca commit bdbcd38
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 46 deletions.
44 changes: 26 additions & 18 deletions pkg/kwokctl/components/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 10 additions & 8 deletions pkg/kwokctl/runtime/binary/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions pkg/kwokctl/runtime/compose/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions pkg/kwokctl/runtime/kind/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bdbcd38

Please sign in to comment.