Skip to content

Commit b35911f

Browse files
Mark metrics-bind-address as deprecated
Signed-off-by: Furkat Gofurov <[email protected]>
1 parent 35977d1 commit b35911f

File tree

7 files changed

+17
-0
lines changed

7 files changed

+17
-0
lines changed

cmd/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var (
5454
setupLog = ctrl.Log.WithName("setup")
5555

5656
// flags.
57+
metricsBindAddr string
5758
enableLeaderElection bool
5859
leaderElectionLeaseDuration time.Duration
5960
leaderElectionRenewDeadline time.Duration
@@ -83,6 +84,11 @@ func init() {
8384

8485
// InitFlags initializes the flags.
8586
func InitFlags(fs *pflag.FlagSet) {
87+
fs.StringVar(&metricsBindAddr, "metrics-bind-addr", "localhost:8080",
88+
"The address the metric endpoint binds to.")
89+
_ = fs.MarkDeprecated("metrics-bind-addr", "Please use --diagnostics-address instead. To continue to serve"+
90+
"metrics via http and without authentication/authorization set --insecure-diagnostics as well.")
91+
8692
fs.BoolVar(&enableLeaderElection, "leader-elect", false,
8793
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
8894

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ spec:
149149
containers:
150150
- name: manager
151151
args:
152+
- --metrics-bind-addr=:8080
152153
- --leader-elect
153154
- --leader-elect-retry-period=5s
154155
- "--diagnostics-address=${CAPI_OPERATOR_DIAGNOSTICS_ADDRESS:=:8443}"

hack/charts/cluster-api-operator/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ spec:
6363
{{- if .Values.healthAddr }}
6464
- --health-addr={{ .Values.healthAddr }}
6565
{{- end }}
66+
{{- if .Values.metricsBindAddr }}
67+
- --metrics-bind-addr={{ .Values.metricsBindAddr }}
68+
{{- end }}
6669
{{- if .Values.diagnosticsAddress }}
6770
- --diagnostics-address={{ .Values.diagnosticsAddress }}
6871
{{- end }}

hack/charts/cluster-api-operator/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ image:
2727
tag: dev
2828
pullPolicy: IfNotPresent
2929
healthAddr: ":8081"
30+
metricsBindAddr: "127.0.0.1:8080"
3031
diagnosticsAddress: "8443"
3132
insecureDiagnostics: false
3233
imagePullSecrets: {}

internal/controller/component_customizer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ func customizeManagerContainer(mSpec *operatorv1.ManagerSpec, c *corev1.Containe
190190
c.Args = leaderElectionArgs(mSpec.LeaderElection, c.Args)
191191
}
192192

193+
if mSpec.Metrics.BindAddress != "" {
194+
c.Args = setArgs(c.Args, "--metrics-bind-addr", mSpec.Metrics.BindAddress)
195+
}
196+
193197
// webhooks
194198
if mSpec.Webhook.Host != "" {
195199
c.Args = setArgs(c.Args, "--webhook-host", mSpec.Webhook.Host)

internal/controller/component_customizer_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ func TestCustomizeDeployment(t *testing.T) {
518518
"--leader-elect-lease-duration=25200s",
519519
"--leader-elect-renew-deadline=25200s",
520520
"--leader-elect-retry-period=25200s",
521+
"--metrics-bind-addr=:4567",
521522
"--webhook-cert-dir=/tmp/certs",
522523
"--sync-period=25200s",
523524
"--profiler-address=localhost:1234",

test/e2e/resources/full-chart-install.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14091,6 +14091,7 @@ spec:
1409114091
- args:
1409214092
- --v=2
1409314093
- --health-addr=:8081
14094+
- --metrics-bind-addr=127.0.0.1:8080
1409414095
- --diagnostics-address=8443
1409514096
- --leader-elect=true
1409614097
command:

0 commit comments

Comments
 (0)