From 0e6ef6459f6d88e3ae5fe8196fb4e7419f6799c7 Mon Sep 17 00:00:00 2001 From: laxmikantbpandhare Date: Mon, 10 Oct 2022 16:38:44 -0700 Subject: [PATCH 1/6] updated templates for component config --- .../templates/config/kdefault/manager_auth_proxy_patch.go | 2 +- .../templates/config/kdefault/manager_auth_proxy_patch.go | 2 +- .../config/default/manager_auth_proxy_patch.yaml | 5 ----- .../config/default/manager_auth_proxy_patch.yaml | 5 +++++ .../config/default/manager_auth_proxy_patch.yaml | 5 ----- .../config/default/manager_auth_proxy_patch.yaml | 5 ----- .../project-v3/config/default/manager_auth_proxy_patch.yaml | 5 ----- .../config/default/manager_auth_proxy_patch.yaml | 5 ----- .../config/default/manager_auth_proxy_patch.yaml | 5 +++++ .../config/default/manager_auth_proxy_patch.yaml | 5 ----- .../config/default/manager_auth_proxy_patch.yaml | 5 ----- .../project-v4/config/default/manager_auth_proxy_patch.yaml | 5 ----- 12 files changed, 12 insertions(+), 42 deletions(-) diff --git a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go index f5d883c4b1..c8945a7849 100644 --- a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go +++ b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go @@ -93,7 +93,7 @@ spec: requests: cpu: 5m memory: 64Mi -{{- if not .ComponentConfig }} +{{- if .ComponentConfig }} - name: manager args: - "--health-probe-bind-address=:8081" diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go index f5d883c4b1..c8945a7849 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go +++ b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go @@ -93,7 +93,7 @@ spec: requests: cpu: 5m memory: 64Mi -{{- if not .ComponentConfig }} +{{- if .ComponentConfig }} - name: manager args: - "--health-probe-bind-address=:8081" diff --git a/testdata/project-v3-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml index 687c4a7a27..caf52d8250 100644 --- a/testdata/project-v3-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v3-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml @@ -48,8 +48,3 @@ spec: requests: cpu: 5m memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" diff --git a/testdata/project-v3-config/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3-config/config/default/manager_auth_proxy_patch.yaml index caf52d8250..687c4a7a27 100644 --- a/testdata/project-v3-config/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v3-config/config/default/manager_auth_proxy_patch.yaml @@ -48,3 +48,8 @@ spec: requests: cpu: 5m memory: 64Mi + - name: manager + args: + - "--health-probe-bind-address=:8081" + - "--metrics-bind-address=127.0.0.1:8080" + - "--leader-elect" diff --git a/testdata/project-v3-multigroup/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3-multigroup/config/default/manager_auth_proxy_patch.yaml index 687c4a7a27..caf52d8250 100644 --- a/testdata/project-v3-multigroup/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v3-multigroup/config/default/manager_auth_proxy_patch.yaml @@ -48,8 +48,3 @@ spec: requests: cpu: 5m memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" diff --git a/testdata/project-v3-with-deploy-image/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3-with-deploy-image/config/default/manager_auth_proxy_patch.yaml index 687c4a7a27..caf52d8250 100644 --- a/testdata/project-v3-with-deploy-image/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v3-with-deploy-image/config/default/manager_auth_proxy_patch.yaml @@ -48,8 +48,3 @@ spec: requests: cpu: 5m memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" diff --git a/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml index 687c4a7a27..caf52d8250 100644 --- a/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml @@ -48,8 +48,3 @@ spec: requests: cpu: 5m memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" diff --git a/testdata/project-v4-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml index 687c4a7a27..caf52d8250 100644 --- a/testdata/project-v4-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v4-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml @@ -48,8 +48,3 @@ spec: requests: cpu: 5m memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" diff --git a/testdata/project-v4-config/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4-config/config/default/manager_auth_proxy_patch.yaml index caf52d8250..687c4a7a27 100644 --- a/testdata/project-v4-config/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v4-config/config/default/manager_auth_proxy_patch.yaml @@ -48,3 +48,8 @@ spec: requests: cpu: 5m memory: 64Mi + - name: manager + args: + - "--health-probe-bind-address=:8081" + - "--metrics-bind-address=127.0.0.1:8080" + - "--leader-elect" diff --git a/testdata/project-v4-multigroup/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4-multigroup/config/default/manager_auth_proxy_patch.yaml index 687c4a7a27..caf52d8250 100644 --- a/testdata/project-v4-multigroup/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v4-multigroup/config/default/manager_auth_proxy_patch.yaml @@ -48,8 +48,3 @@ spec: requests: cpu: 5m memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" diff --git a/testdata/project-v4-with-deploy-image/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4-with-deploy-image/config/default/manager_auth_proxy_patch.yaml index 687c4a7a27..caf52d8250 100644 --- a/testdata/project-v4-with-deploy-image/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v4-with-deploy-image/config/default/manager_auth_proxy_patch.yaml @@ -48,8 +48,3 @@ spec: requests: cpu: 5m memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" diff --git a/testdata/project-v4/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4/config/default/manager_auth_proxy_patch.yaml index 687c4a7a27..caf52d8250 100644 --- a/testdata/project-v4/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v4/config/default/manager_auth_proxy_patch.yaml @@ -48,8 +48,3 @@ spec: requests: cpu: 5m memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" From f5af5326421075b18f2232373ade6f1ba410e207 Mon Sep 17 00:00:00 2001 From: laxmikantbpandhare Date: Mon, 10 Oct 2022 18:04:37 -0700 Subject: [PATCH 2/6] updates --- .../v3/scaffolds/internal/templates/main.go | 4 +- testdata/project-v3-addon-and-grafana/main.go | 43 +++++++------------ testdata/project-v3-config/main.go | 43 ++++++++++++------- testdata/project-v3-multigroup/main.go | 43 +++++++------------ testdata/project-v3-with-deploy-image/main.go | 43 +++++++------------ testdata/project-v3/main.go | 43 +++++++------------ testdata/project-v4-addon-and-grafana/main.go | 43 +++++++------------ testdata/project-v4-config/main.go | 43 ++++++++++++------- testdata/project-v4-multigroup/main.go | 43 +++++++------------ testdata/project-v4-with-deploy-image/main.go | 43 +++++++------------ testdata/project-v4/main.go | 43 +++++++------------ 11 files changed, 184 insertions(+), 250 deletions(-) diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go index e450584fbb..097947a671 100644 --- a/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go +++ b/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go @@ -213,7 +213,7 @@ func init() { } func main() { -{{- if not .ComponentConfig }} +{{- if .ComponentConfig }} var metricsAddr string var enableLeaderElection bool var probeAddr string @@ -237,7 +237,7 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) -{{ if not .ComponentConfig }} +{{ if .ComponentConfig }} mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, MetricsBindAddress: metricsAddr, diff --git a/testdata/project-v3-addon-and-grafana/main.go b/testdata/project-v3-addon-and-grafana/main.go index 8ca605947a..b69d575403 100644 --- a/testdata/project-v3-addon-and-grafana/main.go +++ b/testdata/project-v3-addon-and-grafana/main.go @@ -49,14 +49,11 @@ func init() { } func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - 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.") + var configFile string + flag.StringVar(&configFile, "config", "", + "The controller 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.") opts := zap.Options{ Development: true, } @@ -65,25 +62,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "5a3ee359.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) + var err error + options := ctrl.Options{Scheme: scheme} + if configFile != "" { + options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + if err != nil { + setupLog.Error(err, "unable to load the config file") + os.Exit(1) + } + } + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v3-config/main.go b/testdata/project-v3-config/main.go index d3fd27640f..f3a4f0bfc2 100644 --- a/testdata/project-v3-config/main.go +++ b/testdata/project-v3-config/main.go @@ -49,11 +49,14 @@ func init() { } func main() { - var configFile string - flag.StringVar(&configFile, "config", "", - "The controller 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.") + var metricsAddr string + var enableLeaderElection bool + var probeAddr string + 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.") opts := zap.Options{ Development: true, } @@ -62,17 +65,25 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - var err error - options := ctrl.Options{Scheme: scheme} - if configFile != "" { - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) - if err != nil { - setupLog.Error(err, "unable to load the config file") - os.Exit(1) - } - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: "6858fb70.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, + }) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v3-multigroup/main.go b/testdata/project-v3-multigroup/main.go index 55e34cb64f..d6e13be105 100644 --- a/testdata/project-v3-multigroup/main.go +++ b/testdata/project-v3-multigroup/main.go @@ -74,14 +74,11 @@ func init() { } func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - 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.") + var configFile string + flag.StringVar(&configFile, "config", "", + "The controller 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.") opts := zap.Options{ Development: true, } @@ -90,25 +87,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "14be1926.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) + var err error + options := ctrl.Options{Scheme: scheme} + if configFile != "" { + options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + if err != nil { + setupLog.Error(err, "unable to load the config file") + os.Exit(1) + } + } + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v3-with-deploy-image/main.go b/testdata/project-v3-with-deploy-image/main.go index 8d297f952d..315d0de845 100644 --- a/testdata/project-v3-with-deploy-image/main.go +++ b/testdata/project-v3-with-deploy-image/main.go @@ -49,14 +49,11 @@ func init() { } func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - 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.") + var configFile string + flag.StringVar(&configFile, "config", "", + "The controller 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.") opts := zap.Options{ Development: true, } @@ -65,25 +62,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "4d73a076.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) + var err error + options := ctrl.Options{Scheme: scheme} + if configFile != "" { + options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + if err != nil { + setupLog.Error(err, "unable to load the config file") + os.Exit(1) + } + } + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v3/main.go b/testdata/project-v3/main.go index 81da09f388..f8bb745743 100644 --- a/testdata/project-v3/main.go +++ b/testdata/project-v3/main.go @@ -49,14 +49,11 @@ func init() { } func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - 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.") + var configFile string + flag.StringVar(&configFile, "config", "", + "The controller 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.") opts := zap.Options{ Development: true, } @@ -65,25 +62,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "dd1da13f.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) + var err error + options := ctrl.Options{Scheme: scheme} + if configFile != "" { + options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + if err != nil { + setupLog.Error(err, "unable to load the config file") + os.Exit(1) + } + } + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v4-addon-and-grafana/main.go b/testdata/project-v4-addon-and-grafana/main.go index 6428f01e49..c1256c44cd 100644 --- a/testdata/project-v4-addon-and-grafana/main.go +++ b/testdata/project-v4-addon-and-grafana/main.go @@ -49,14 +49,11 @@ func init() { } func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - 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.") + var configFile string + flag.StringVar(&configFile, "config", "", + "The controller 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.") opts := zap.Options{ Development: true, } @@ -65,25 +62,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "52a2c700.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) + var err error + options := ctrl.Options{Scheme: scheme} + if configFile != "" { + options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + if err != nil { + setupLog.Error(err, "unable to load the config file") + os.Exit(1) + } + } + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v4-config/main.go b/testdata/project-v4-config/main.go index 296c9d8af2..0b95add5ca 100644 --- a/testdata/project-v4-config/main.go +++ b/testdata/project-v4-config/main.go @@ -49,11 +49,14 @@ func init() { } func main() { - var configFile string - flag.StringVar(&configFile, "config", "", - "The controller 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.") + var metricsAddr string + var enableLeaderElection bool + var probeAddr string + 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.") opts := zap.Options{ Development: true, } @@ -62,17 +65,25 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - var err error - options := ctrl.Options{Scheme: scheme} - if configFile != "" { - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) - if err != nil { - setupLog.Error(err, "unable to load the config file") - os.Exit(1) - } - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: "89f7a333.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, + }) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v4-multigroup/main.go b/testdata/project-v4-multigroup/main.go index fb53924ca8..0269bf05d2 100644 --- a/testdata/project-v4-multigroup/main.go +++ b/testdata/project-v4-multigroup/main.go @@ -74,14 +74,11 @@ func init() { } func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - 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.") + var configFile string + flag.StringVar(&configFile, "config", "", + "The controller 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.") opts := zap.Options{ Development: true, } @@ -90,25 +87,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "3e9f67a9.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) + var err error + options := ctrl.Options{Scheme: scheme} + if configFile != "" { + options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + if err != nil { + setupLog.Error(err, "unable to load the config file") + os.Exit(1) + } + } + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v4-with-deploy-image/main.go b/testdata/project-v4-with-deploy-image/main.go index 59d643f172..079f4781fb 100644 --- a/testdata/project-v4-with-deploy-image/main.go +++ b/testdata/project-v4-with-deploy-image/main.go @@ -49,14 +49,11 @@ func init() { } func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - 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.") + var configFile string + flag.StringVar(&configFile, "config", "", + "The controller 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.") opts := zap.Options{ Development: true, } @@ -65,25 +62,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "1836d577.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) + var err error + options := ctrl.Options{Scheme: scheme} + if configFile != "" { + options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + if err != nil { + setupLog.Error(err, "unable to load the config file") + os.Exit(1) + } + } + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v4/main.go b/testdata/project-v4/main.go index 1c44a24f4d..f5aff09631 100644 --- a/testdata/project-v4/main.go +++ b/testdata/project-v4/main.go @@ -49,14 +49,11 @@ func init() { } func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - 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.") + var configFile string + flag.StringVar(&configFile, "config", "", + "The controller 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.") opts := zap.Options{ Development: true, } @@ -65,25 +62,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "da1d9c86.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) + var err error + options := ctrl.Options{Scheme: scheme} + if configFile != "" { + options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + if err != nil { + setupLog.Error(err, "unable to load the config file") + os.Exit(1) + } + } + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) From f5434600241ccbce40eaa49b24e0d27dd33b1dca Mon Sep 17 00:00:00 2001 From: laxmikantbpandhare Date: Mon, 10 Oct 2022 21:05:15 -0700 Subject: [PATCH 3/6] update --- test/e2e/v3/generate_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/v3/generate_test.go b/test/e2e/v3/generate_test.go index b6522881fd..53282b647d 100644 --- a/test/e2e/v3/generate_test.go +++ b/test/e2e/v3/generate_test.go @@ -44,6 +44,7 @@ func GenerateV3(kbc *utils.TestContext) { "--project-version", "3", "--domain", kbc.Domain, "--fetch-deps=false", + "--component-config=true", ) ExpectWithOffset(1, err).NotTo(HaveOccurred()) From 763402c1752098eeda02a5dc1c578085e089c34f Mon Sep 17 00:00:00 2001 From: laxmikantbpandhare Date: Mon, 10 Oct 2022 22:11:52 -0700 Subject: [PATCH 4/6] update revert main.go --- .../v3/scaffolds/internal/templates/main.go | 4 +- testdata/project-v3-addon-and-grafana/main.go | 43 ++++++++++++------- testdata/project-v3-config/main.go | 43 +++++++------------ testdata/project-v3-multigroup/main.go | 43 ++++++++++++------- testdata/project-v3-with-deploy-image/main.go | 43 ++++++++++++------- testdata/project-v3/main.go | 43 ++++++++++++------- testdata/project-v4-addon-and-grafana/main.go | 43 ++++++++++++------- testdata/project-v4-config/main.go | 43 +++++++------------ testdata/project-v4-multigroup/main.go | 43 ++++++++++++------- testdata/project-v4-with-deploy-image/main.go | 43 ++++++++++++------- testdata/project-v4/main.go | 43 ++++++++++++------- 11 files changed, 250 insertions(+), 184 deletions(-) diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go index 097947a671..e450584fbb 100644 --- a/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go +++ b/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go @@ -213,7 +213,7 @@ func init() { } func main() { -{{- if .ComponentConfig }} +{{- if not .ComponentConfig }} var metricsAddr string var enableLeaderElection bool var probeAddr string @@ -237,7 +237,7 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) -{{ if .ComponentConfig }} +{{ if not .ComponentConfig }} mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, MetricsBindAddress: metricsAddr, diff --git a/testdata/project-v3-addon-and-grafana/main.go b/testdata/project-v3-addon-and-grafana/main.go index b69d575403..8ca605947a 100644 --- a/testdata/project-v3-addon-and-grafana/main.go +++ b/testdata/project-v3-addon-and-grafana/main.go @@ -49,11 +49,14 @@ func init() { } func main() { - var configFile string - flag.StringVar(&configFile, "config", "", - "The controller 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.") + var metricsAddr string + var enableLeaderElection bool + var probeAddr string + 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.") opts := zap.Options{ Development: true, } @@ -62,17 +65,25 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - var err error - options := ctrl.Options{Scheme: scheme} - if configFile != "" { - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) - if err != nil { - setupLog.Error(err, "unable to load the config file") - os.Exit(1) - } - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: "5a3ee359.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, + }) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v3-config/main.go b/testdata/project-v3-config/main.go index f3a4f0bfc2..d3fd27640f 100644 --- a/testdata/project-v3-config/main.go +++ b/testdata/project-v3-config/main.go @@ -49,14 +49,11 @@ func init() { } func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - 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.") + var configFile string + flag.StringVar(&configFile, "config", "", + "The controller 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.") opts := zap.Options{ Development: true, } @@ -65,25 +62,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "6858fb70.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) + var err error + options := ctrl.Options{Scheme: scheme} + if configFile != "" { + options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + if err != nil { + setupLog.Error(err, "unable to load the config file") + os.Exit(1) + } + } + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v3-multigroup/main.go b/testdata/project-v3-multigroup/main.go index d6e13be105..55e34cb64f 100644 --- a/testdata/project-v3-multigroup/main.go +++ b/testdata/project-v3-multigroup/main.go @@ -74,11 +74,14 @@ func init() { } func main() { - var configFile string - flag.StringVar(&configFile, "config", "", - "The controller 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.") + var metricsAddr string + var enableLeaderElection bool + var probeAddr string + 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.") opts := zap.Options{ Development: true, } @@ -87,17 +90,25 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - var err error - options := ctrl.Options{Scheme: scheme} - if configFile != "" { - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) - if err != nil { - setupLog.Error(err, "unable to load the config file") - os.Exit(1) - } - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: "14be1926.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, + }) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v3-with-deploy-image/main.go b/testdata/project-v3-with-deploy-image/main.go index 315d0de845..8d297f952d 100644 --- a/testdata/project-v3-with-deploy-image/main.go +++ b/testdata/project-v3-with-deploy-image/main.go @@ -49,11 +49,14 @@ func init() { } func main() { - var configFile string - flag.StringVar(&configFile, "config", "", - "The controller 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.") + var metricsAddr string + var enableLeaderElection bool + var probeAddr string + 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.") opts := zap.Options{ Development: true, } @@ -62,17 +65,25 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - var err error - options := ctrl.Options{Scheme: scheme} - if configFile != "" { - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) - if err != nil { - setupLog.Error(err, "unable to load the config file") - os.Exit(1) - } - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: "4d73a076.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, + }) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v3/main.go b/testdata/project-v3/main.go index f8bb745743..81da09f388 100644 --- a/testdata/project-v3/main.go +++ b/testdata/project-v3/main.go @@ -49,11 +49,14 @@ func init() { } func main() { - var configFile string - flag.StringVar(&configFile, "config", "", - "The controller 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.") + var metricsAddr string + var enableLeaderElection bool + var probeAddr string + 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.") opts := zap.Options{ Development: true, } @@ -62,17 +65,25 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - var err error - options := ctrl.Options{Scheme: scheme} - if configFile != "" { - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) - if err != nil { - setupLog.Error(err, "unable to load the config file") - os.Exit(1) - } - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: "dd1da13f.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, + }) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v4-addon-and-grafana/main.go b/testdata/project-v4-addon-and-grafana/main.go index c1256c44cd..6428f01e49 100644 --- a/testdata/project-v4-addon-and-grafana/main.go +++ b/testdata/project-v4-addon-and-grafana/main.go @@ -49,11 +49,14 @@ func init() { } func main() { - var configFile string - flag.StringVar(&configFile, "config", "", - "The controller 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.") + var metricsAddr string + var enableLeaderElection bool + var probeAddr string + 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.") opts := zap.Options{ Development: true, } @@ -62,17 +65,25 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - var err error - options := ctrl.Options{Scheme: scheme} - if configFile != "" { - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) - if err != nil { - setupLog.Error(err, "unable to load the config file") - os.Exit(1) - } - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: "52a2c700.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, + }) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v4-config/main.go b/testdata/project-v4-config/main.go index 0b95add5ca..296c9d8af2 100644 --- a/testdata/project-v4-config/main.go +++ b/testdata/project-v4-config/main.go @@ -49,14 +49,11 @@ func init() { } func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - 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.") + var configFile string + flag.StringVar(&configFile, "config", "", + "The controller 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.") opts := zap.Options{ Development: true, } @@ -65,25 +62,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "89f7a333.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) + var err error + options := ctrl.Options{Scheme: scheme} + if configFile != "" { + options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + if err != nil { + setupLog.Error(err, "unable to load the config file") + os.Exit(1) + } + } + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v4-multigroup/main.go b/testdata/project-v4-multigroup/main.go index 0269bf05d2..fb53924ca8 100644 --- a/testdata/project-v4-multigroup/main.go +++ b/testdata/project-v4-multigroup/main.go @@ -74,11 +74,14 @@ func init() { } func main() { - var configFile string - flag.StringVar(&configFile, "config", "", - "The controller 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.") + var metricsAddr string + var enableLeaderElection bool + var probeAddr string + 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.") opts := zap.Options{ Development: true, } @@ -87,17 +90,25 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - var err error - options := ctrl.Options{Scheme: scheme} - if configFile != "" { - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) - if err != nil { - setupLog.Error(err, "unable to load the config file") - os.Exit(1) - } - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: "3e9f67a9.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, + }) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v4-with-deploy-image/main.go b/testdata/project-v4-with-deploy-image/main.go index 079f4781fb..59d643f172 100644 --- a/testdata/project-v4-with-deploy-image/main.go +++ b/testdata/project-v4-with-deploy-image/main.go @@ -49,11 +49,14 @@ func init() { } func main() { - var configFile string - flag.StringVar(&configFile, "config", "", - "The controller 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.") + var metricsAddr string + var enableLeaderElection bool + var probeAddr string + 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.") opts := zap.Options{ Development: true, } @@ -62,17 +65,25 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - var err error - options := ctrl.Options{Scheme: scheme} - if configFile != "" { - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) - if err != nil { - setupLog.Error(err, "unable to load the config file") - os.Exit(1) - } - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: "1836d577.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, + }) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) diff --git a/testdata/project-v4/main.go b/testdata/project-v4/main.go index f5aff09631..1c44a24f4d 100644 --- a/testdata/project-v4/main.go +++ b/testdata/project-v4/main.go @@ -49,11 +49,14 @@ func init() { } func main() { - var configFile string - flag.StringVar(&configFile, "config", "", - "The controller 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.") + var metricsAddr string + var enableLeaderElection bool + var probeAddr string + 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.") opts := zap.Options{ Development: true, } @@ -62,17 +65,25 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - var err error - options := ctrl.Options{Scheme: scheme} - if configFile != "" { - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) - if err != nil { - setupLog.Error(err, "unable to load the config file") - os.Exit(1) - } - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: "da1d9c86.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, + }) if err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) From 753ebd66b8ddaa79582a553a015749ec285769fd Mon Sep 17 00:00:00 2001 From: laxmikantbpandhare Date: Mon, 10 Oct 2022 22:13:52 -0700 Subject: [PATCH 5/6] update revert main.go --- test/e2e/v3/generate_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/v3/generate_test.go b/test/e2e/v3/generate_test.go index 53282b647d..b6522881fd 100644 --- a/test/e2e/v3/generate_test.go +++ b/test/e2e/v3/generate_test.go @@ -44,7 +44,6 @@ func GenerateV3(kbc *utils.TestContext) { "--project-version", "3", "--domain", kbc.Domain, "--fetch-deps=false", - "--component-config=true", ) ExpectWithOffset(1, err).NotTo(HaveOccurred()) From b2e29062353f5c1f6d0fb178ef6934463ba64351 Mon Sep 17 00:00:00 2001 From: laxmikantbpandhare Date: Mon, 10 Oct 2022 23:40:02 -0700 Subject: [PATCH 6/6] revert changes and go thru docs once --- .../templates/config/kdefault/manager_auth_proxy_patch.go | 2 +- .../v1/scaffolds/internal/templates/config/manager/config.go | 2 +- .../templates/config/kdefault/manager_auth_proxy_patch.go | 2 +- .../scaffolds/internal/templates/config/manager/config.go | 2 +- .../config/default/manager_auth_proxy_patch.yaml | 5 +++++ .../project-v3-addon-and-grafana/config/manager/manager.yaml | 2 ++ .../config/default/manager_auth_proxy_patch.yaml | 5 ----- testdata/project-v3-config/config/manager/manager.yaml | 2 -- .../config/default/manager_auth_proxy_patch.yaml | 5 +++++ testdata/project-v3-multigroup/config/manager/manager.yaml | 2 ++ .../config/default/manager_auth_proxy_patch.yaml | 5 +++++ .../project-v3-with-deploy-image/config/manager/manager.yaml | 2 ++ .../project-v3/config/default/manager_auth_proxy_patch.yaml | 5 +++++ testdata/project-v3/config/manager/manager.yaml | 2 ++ .../config/default/manager_auth_proxy_patch.yaml | 5 +++++ .../project-v4-addon-and-grafana/config/manager/manager.yaml | 2 ++ .../config/default/manager_auth_proxy_patch.yaml | 5 ----- testdata/project-v4-config/config/manager/manager.yaml | 2 -- .../config/default/manager_auth_proxy_patch.yaml | 5 +++++ testdata/project-v4-multigroup/config/manager/manager.yaml | 2 ++ .../config/default/manager_auth_proxy_patch.yaml | 5 +++++ .../project-v4-with-deploy-image/config/manager/manager.yaml | 2 ++ .../project-v4/config/default/manager_auth_proxy_patch.yaml | 5 +++++ testdata/project-v4/config/manager/manager.yaml | 2 ++ 24 files changed, 60 insertions(+), 18 deletions(-) diff --git a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go index c8945a7849..f5d883c4b1 100644 --- a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go +++ b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go @@ -93,7 +93,7 @@ spec: requests: cpu: 5m memory: 64Mi -{{- if .ComponentConfig }} +{{- if not .ComponentConfig }} - name: manager args: - "--health-probe-bind-address=:8081" diff --git a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/config.go b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/config.go index 1751290208..367d894862 100644 --- a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/config.go +++ b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/config.go @@ -115,7 +115,7 @@ spec: containers: - command: - /manager -{{- if .ComponentConfig }} +{{- if not .ComponentConfig }} args: - --leader-elect {{- end }} diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go index c8945a7849..f5d883c4b1 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go +++ b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go @@ -93,7 +93,7 @@ spec: requests: cpu: 5m memory: 64Mi -{{- if .ComponentConfig }} +{{- if not .ComponentConfig }} - name: manager args: - "--health-probe-bind-address=:8081" diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/config.go b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/config.go index 1751290208..367d894862 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/config.go +++ b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/config.go @@ -115,7 +115,7 @@ spec: containers: - command: - /manager -{{- if .ComponentConfig }} +{{- if not .ComponentConfig }} args: - --leader-elect {{- end }} diff --git a/testdata/project-v3-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml index caf52d8250..687c4a7a27 100644 --- a/testdata/project-v3-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v3-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml @@ -48,3 +48,8 @@ spec: requests: cpu: 5m memory: 64Mi + - name: manager + args: + - "--health-probe-bind-address=:8081" + - "--metrics-bind-address=127.0.0.1:8080" + - "--leader-elect" diff --git a/testdata/project-v3-addon-and-grafana/config/manager/manager.yaml b/testdata/project-v3-addon-and-grafana/config/manager/manager.yaml index 6422d7b459..381292c1da 100644 --- a/testdata/project-v3-addon-and-grafana/config/manager/manager.yaml +++ b/testdata/project-v3-addon-and-grafana/config/manager/manager.yaml @@ -68,6 +68,8 @@ spec: containers: - command: - /manager + args: + - --leader-elect image: controller:latest name: manager securityContext: diff --git a/testdata/project-v3-config/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3-config/config/default/manager_auth_proxy_patch.yaml index 687c4a7a27..caf52d8250 100644 --- a/testdata/project-v3-config/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v3-config/config/default/manager_auth_proxy_patch.yaml @@ -48,8 +48,3 @@ spec: requests: cpu: 5m memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" diff --git a/testdata/project-v3-config/config/manager/manager.yaml b/testdata/project-v3-config/config/manager/manager.yaml index 35a7d0256a..8531209ae4 100644 --- a/testdata/project-v3-config/config/manager/manager.yaml +++ b/testdata/project-v3-config/config/manager/manager.yaml @@ -68,8 +68,6 @@ spec: containers: - command: - /manager - args: - - --leader-elect image: controller:latest name: manager securityContext: diff --git a/testdata/project-v3-multigroup/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3-multigroup/config/default/manager_auth_proxy_patch.yaml index caf52d8250..687c4a7a27 100644 --- a/testdata/project-v3-multigroup/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v3-multigroup/config/default/manager_auth_proxy_patch.yaml @@ -48,3 +48,8 @@ spec: requests: cpu: 5m memory: 64Mi + - name: manager + args: + - "--health-probe-bind-address=:8081" + - "--metrics-bind-address=127.0.0.1:8080" + - "--leader-elect" diff --git a/testdata/project-v3-multigroup/config/manager/manager.yaml b/testdata/project-v3-multigroup/config/manager/manager.yaml index a0a64a52ab..7bb3f65a0b 100644 --- a/testdata/project-v3-multigroup/config/manager/manager.yaml +++ b/testdata/project-v3-multigroup/config/manager/manager.yaml @@ -68,6 +68,8 @@ spec: containers: - command: - /manager + args: + - --leader-elect image: controller:latest name: manager securityContext: diff --git a/testdata/project-v3-with-deploy-image/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3-with-deploy-image/config/default/manager_auth_proxy_patch.yaml index caf52d8250..687c4a7a27 100644 --- a/testdata/project-v3-with-deploy-image/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v3-with-deploy-image/config/default/manager_auth_proxy_patch.yaml @@ -48,3 +48,8 @@ spec: requests: cpu: 5m memory: 64Mi + - name: manager + args: + - "--health-probe-bind-address=:8081" + - "--metrics-bind-address=127.0.0.1:8080" + - "--leader-elect" diff --git a/testdata/project-v3-with-deploy-image/config/manager/manager.yaml b/testdata/project-v3-with-deploy-image/config/manager/manager.yaml index a08c40d2ff..485fb40a81 100644 --- a/testdata/project-v3-with-deploy-image/config/manager/manager.yaml +++ b/testdata/project-v3-with-deploy-image/config/manager/manager.yaml @@ -68,6 +68,8 @@ spec: containers: - command: - /manager + args: + - --leader-elect image: controller:latest name: manager env: diff --git a/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml index caf52d8250..687c4a7a27 100644 --- a/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml @@ -48,3 +48,8 @@ spec: requests: cpu: 5m memory: 64Mi + - name: manager + args: + - "--health-probe-bind-address=:8081" + - "--metrics-bind-address=127.0.0.1:8080" + - "--leader-elect" diff --git a/testdata/project-v3/config/manager/manager.yaml b/testdata/project-v3/config/manager/manager.yaml index 65f82f0371..1760f9b6b5 100644 --- a/testdata/project-v3/config/manager/manager.yaml +++ b/testdata/project-v3/config/manager/manager.yaml @@ -68,6 +68,8 @@ spec: containers: - command: - /manager + args: + - --leader-elect image: controller:latest name: manager securityContext: diff --git a/testdata/project-v4-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml index caf52d8250..687c4a7a27 100644 --- a/testdata/project-v4-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v4-addon-and-grafana/config/default/manager_auth_proxy_patch.yaml @@ -48,3 +48,8 @@ spec: requests: cpu: 5m memory: 64Mi + - name: manager + args: + - "--health-probe-bind-address=:8081" + - "--metrics-bind-address=127.0.0.1:8080" + - "--leader-elect" diff --git a/testdata/project-v4-addon-and-grafana/config/manager/manager.yaml b/testdata/project-v4-addon-and-grafana/config/manager/manager.yaml index 9355e0ee2a..3bce5b03c3 100644 --- a/testdata/project-v4-addon-and-grafana/config/manager/manager.yaml +++ b/testdata/project-v4-addon-and-grafana/config/manager/manager.yaml @@ -68,6 +68,8 @@ spec: containers: - command: - /manager + args: + - --leader-elect image: controller:latest name: manager securityContext: diff --git a/testdata/project-v4-config/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4-config/config/default/manager_auth_proxy_patch.yaml index 687c4a7a27..caf52d8250 100644 --- a/testdata/project-v4-config/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v4-config/config/default/manager_auth_proxy_patch.yaml @@ -48,8 +48,3 @@ spec: requests: cpu: 5m memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" diff --git a/testdata/project-v4-config/config/manager/manager.yaml b/testdata/project-v4-config/config/manager/manager.yaml index 41484f7da4..97ce064aaa 100644 --- a/testdata/project-v4-config/config/manager/manager.yaml +++ b/testdata/project-v4-config/config/manager/manager.yaml @@ -68,8 +68,6 @@ spec: containers: - command: - /manager - args: - - --leader-elect image: controller:latest name: manager securityContext: diff --git a/testdata/project-v4-multigroup/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4-multigroup/config/default/manager_auth_proxy_patch.yaml index caf52d8250..687c4a7a27 100644 --- a/testdata/project-v4-multigroup/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v4-multigroup/config/default/manager_auth_proxy_patch.yaml @@ -48,3 +48,8 @@ spec: requests: cpu: 5m memory: 64Mi + - name: manager + args: + - "--health-probe-bind-address=:8081" + - "--metrics-bind-address=127.0.0.1:8080" + - "--leader-elect" diff --git a/testdata/project-v4-multigroup/config/manager/manager.yaml b/testdata/project-v4-multigroup/config/manager/manager.yaml index 1e6aa05e10..21f5234840 100644 --- a/testdata/project-v4-multigroup/config/manager/manager.yaml +++ b/testdata/project-v4-multigroup/config/manager/manager.yaml @@ -68,6 +68,8 @@ spec: containers: - command: - /manager + args: + - --leader-elect image: controller:latest name: manager securityContext: diff --git a/testdata/project-v4-with-deploy-image/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4-with-deploy-image/config/default/manager_auth_proxy_patch.yaml index caf52d8250..687c4a7a27 100644 --- a/testdata/project-v4-with-deploy-image/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v4-with-deploy-image/config/default/manager_auth_proxy_patch.yaml @@ -48,3 +48,8 @@ spec: requests: cpu: 5m memory: 64Mi + - name: manager + args: + - "--health-probe-bind-address=:8081" + - "--metrics-bind-address=127.0.0.1:8080" + - "--leader-elect" diff --git a/testdata/project-v4-with-deploy-image/config/manager/manager.yaml b/testdata/project-v4-with-deploy-image/config/manager/manager.yaml index 41d49fab11..d6cce184e0 100644 --- a/testdata/project-v4-with-deploy-image/config/manager/manager.yaml +++ b/testdata/project-v4-with-deploy-image/config/manager/manager.yaml @@ -68,6 +68,8 @@ spec: containers: - command: - /manager + args: + - --leader-elect image: controller:latest name: manager env: diff --git a/testdata/project-v4/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4/config/default/manager_auth_proxy_patch.yaml index caf52d8250..687c4a7a27 100644 --- a/testdata/project-v4/config/default/manager_auth_proxy_patch.yaml +++ b/testdata/project-v4/config/default/manager_auth_proxy_patch.yaml @@ -48,3 +48,8 @@ spec: requests: cpu: 5m memory: 64Mi + - name: manager + args: + - "--health-probe-bind-address=:8081" + - "--metrics-bind-address=127.0.0.1:8080" + - "--leader-elect" diff --git a/testdata/project-v4/config/manager/manager.yaml b/testdata/project-v4/config/manager/manager.yaml index ebd0976273..445961a32f 100644 --- a/testdata/project-v4/config/manager/manager.yaml +++ b/testdata/project-v4/config/manager/manager.yaml @@ -68,6 +68,8 @@ spec: containers: - command: - /manager + args: + - --leader-elect image: controller:latest name: manager securityContext: