From 52b2cdb62e3594f39b353665428cf5531cce574c Mon Sep 17 00:00:00 2001 From: dd di cesare Date: Tue, 18 Oct 2022 14:37:47 +0100 Subject: [PATCH] [manager] Setting options via config file --- config/default/kustomization.yaml | 1 + config/manager/manager.yaml | 2 -- main.go | 22 ++++------------------ 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index ca335aaf4..7d9d59f30 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -25,6 +25,7 @@ patchesStrategicMerge: # If you want your controller-manager to expose the /metrics # endpoint w/o any authn/z, please comment the following line. #- manager_auth_proxy_patch.yaml +- manager_config_patch.yaml - manager_metrics_patch.yaml # Mount the controller config file for loading manager configurations diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index afd442ee2..61866a55b 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -27,8 +27,6 @@ spec: containers: - command: - /manager - args: - - --leader-elect env: - name: RELATED_IMAGE_WASMSHIM value: "oci://quay.io/kuadrant/wasm-shim:latest" diff --git a/main.go b/main.go index e1028b9c5..2b6da7929 100644 --- a/main.go +++ b/main.go @@ -93,31 +93,17 @@ func main() { setupLog := log.Log var ( - metricsAddr string - enableLeaderElection bool - probeAddr string - configFile string - err error + configFile string + err error ) - flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") - flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") - flag.BoolVar(&enableLeaderElection, "leader-elect", false, - "Enable leader election for controller manager. "+ - "Enabling this will ensure there is only one active controller manager.") flag.StringVar(&configFile, "config", "", "The operator will load its initial configuration from this file. "+ "Omit this flag to use the default configuration values. "+ "Command-line flags override configuration from this file.") flag.Parse() - options := ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "f139389e.kuadrant.io", - } + options := ctrl.Options{Scheme: scheme} + if configFile != "" { options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) if err != nil {