From 2bdc27ab22db434d422ddec85911d1b430dbac27 Mon Sep 17 00:00:00 2001 From: Mickael Stanislas Date: Thu, 7 Nov 2024 12:05:30 +0100 Subject: [PATCH] fix: healthz/metrics port args kimup-controller --- .goreleaser.yaml | 2 +- cmd/kimup/main.go | 1 - cmd/operator/main.go | 6 ++---- internal/controller/resources_common.go | 5 ++--- manifests/operator/webhook-certificate.yaml | 4 ++-- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 4468c48..f74b5c8 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -40,7 +40,7 @@ builds: env: - CGO_ENABLED=0 ldflags: - - '-X github.com/orange-cloudavenue/kube-image-updater/internal/models/models.Version={{.Tag}}' + - '-X github.com/orange-cloudavenue/kube-image-updater/internal/models.Version={{.Tag}}' dockers: # * KIMUP diff --git a/cmd/kimup/main.go b/cmd/kimup/main.go index 93d52e3..9279be4 100644 --- a/cmd/kimup/main.go +++ b/cmd/kimup/main.go @@ -28,7 +28,6 @@ func init() { metrics.Rules() metrics.Registry() - // TODO add namespace scope // Flag "loglevel" is set in log package flag.Parse() } diff --git a/cmd/operator/main.go b/cmd/operator/main.go index e78b066..49c537f 100644 --- a/cmd/operator/main.go +++ b/cmd/operator/main.go @@ -76,8 +76,6 @@ func main() { ctrl.SetLogger(logrusr.New(log.GetLogger())) - webhook := webhook.NewServer(webhook.Options{Port: models.MutatorDefaultPort}) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, Metrics: metricsserver.Options{ @@ -99,7 +97,7 @@ func main() { }(), LeaderElection: enableLeaderElection, LeaderElectionID: "71be4586.kimup.cloudavenue.io", - WebhookServer: webhook, + WebhookServer: webhook.NewServer(webhook.Options{Port: models.MutatorDefaultPort}), }) if err != nil { log.WithError(err).Error("unable to start manager") @@ -178,7 +176,7 @@ func main() { c <- syscall.SIGINT } - log.Info("Starting operator") + log.WithField("version", models.Version).Info("Starting kimup operator", models.Version) if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { log.WithError(err).Error(err, "problem running manager") c <- syscall.SIGINT diff --git a/internal/controller/resources_common.go b/internal/controller/resources_common.go index 6f0c196..ea14ed1 100644 --- a/internal/controller/resources_common.go +++ b/internal/controller/resources_common.go @@ -24,7 +24,7 @@ func buildKimupArgs(extra v1alpha1.KimupExtraSpec) (args []string) { // set the healthz port healthzPort := extra.Healthz.Port - if healthzPort != 0 { + if healthzPort == 0 { healthzPort = models.HealthzDefaultPort } args = append(args, fmt.Sprintf("--%s=%d", models.HealthzPortFlagName, healthzPort)) @@ -43,7 +43,7 @@ func buildKimupArgs(extra v1alpha1.KimupExtraSpec) (args []string) { // set the metrics port metricsPort := extra.Metrics.Port - if metricsPort != 0 { + if metricsPort == 0 { metricsPort = models.MetricsDefaultPort } @@ -58,7 +58,6 @@ func buildKimupArgs(extra v1alpha1.KimupExtraSpec) (args []string) { args = append(args, fmt.Sprintf("--%s=%s", models.MetricsPathFlagName, metricsPath)) } - // TODO args = append(args, fmt.Sprintf("--%s=%s", models.LogLevelFlagName, extra.LogLevel)) return args diff --git a/manifests/operator/webhook-certificate.yaml b/manifests/operator/webhook-certificate.yaml index 7e49fb8..95b516f 100644 --- a/manifests/operator/webhook-certificate.yaml +++ b/manifests/operator/webhook-certificate.yaml @@ -5,8 +5,8 @@ metadata: namespace: kimup-operator spec: dnsNames: - - mutator.kimup-operator.svc - - mutator.kimup-operator.svc.cluster.local + - kimup-operator.kimup-operator.svc + - kimup-operator.kimup-operator.svc.cluster.local secretName: kimup-webhook-serving-cert issuerRef: kind: Issuer