Skip to content

Commit

Permalink
Mark metrics-bind-address as deprecated
Browse files Browse the repository at this point in the history
Signed-off-by: Furkat Gofurov <furkat.gofurov@suse.com>
  • Loading branch information
furkatgofurov7 committed Nov 30, 2023
1 parent 35977d1 commit b35911f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var (
setupLog = ctrl.Log.WithName("setup")

// flags.
metricsBindAddr string
enableLeaderElection bool
leaderElectionLeaseDuration time.Duration
leaderElectionRenewDeadline time.Duration
Expand Down Expand Up @@ -83,6 +84,11 @@ func init() {

// InitFlags initializes the flags.
func InitFlags(fs *pflag.FlagSet) {
fs.StringVar(&metricsBindAddr, "metrics-bind-addr", "localhost:8080",
"The address the metric endpoint binds to.")
_ = fs.MarkDeprecated("metrics-bind-addr", "Please use --diagnostics-address instead. To continue to serve"+
"metrics via http and without authentication/authorization set --insecure-diagnostics as well.")

fs.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")

Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ spec:
containers:
- name: manager
args:
- --metrics-bind-addr=:8080
- --leader-elect
- --leader-elect-retry-period=5s
- "--diagnostics-address=${CAPI_OPERATOR_DIAGNOSTICS_ADDRESS:=:8443}"
Expand Down
3 changes: 3 additions & 0 deletions hack/charts/cluster-api-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ spec:
{{- if .Values.healthAddr }}
- --health-addr={{ .Values.healthAddr }}
{{- end }}
{{- if .Values.metricsBindAddr }}
- --metrics-bind-addr={{ .Values.metricsBindAddr }}
{{- end }}
{{- if .Values.diagnosticsAddress }}
- --diagnostics-address={{ .Values.diagnosticsAddress }}
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions hack/charts/cluster-api-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ image:
tag: dev
pullPolicy: IfNotPresent
healthAddr: ":8081"
metricsBindAddr: "127.0.0.1:8080"
diagnosticsAddress: "8443"
insecureDiagnostics: false
imagePullSecrets: {}
Expand Down
4 changes: 4 additions & 0 deletions internal/controller/component_customizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ func customizeManagerContainer(mSpec *operatorv1.ManagerSpec, c *corev1.Containe
c.Args = leaderElectionArgs(mSpec.LeaderElection, c.Args)
}

if mSpec.Metrics.BindAddress != "" {
c.Args = setArgs(c.Args, "--metrics-bind-addr", mSpec.Metrics.BindAddress)
}

// webhooks
if mSpec.Webhook.Host != "" {
c.Args = setArgs(c.Args, "--webhook-host", mSpec.Webhook.Host)
Expand Down
1 change: 1 addition & 0 deletions internal/controller/component_customizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ func TestCustomizeDeployment(t *testing.T) {
"--leader-elect-lease-duration=25200s",
"--leader-elect-renew-deadline=25200s",
"--leader-elect-retry-period=25200s",
"--metrics-bind-addr=:4567",
"--webhook-cert-dir=/tmp/certs",
"--sync-period=25200s",
"--profiler-address=localhost:1234",
Expand Down
1 change: 1 addition & 0 deletions test/e2e/resources/full-chart-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14091,6 +14091,7 @@ spec:
- args:
- --v=2
- --health-addr=:8081
- --metrics-bind-addr=127.0.0.1:8080
- --diagnostics-address=8443
- --leader-elect=true
command:
Expand Down

0 comments on commit b35911f

Please sign in to comment.