diff --git a/api/v1alpha2/controllermanagerconfig_types.go b/api/v1alpha2/controllermanagerconfig_types.go index 82425f537..12a3da114 100644 --- a/api/v1alpha2/controllermanagerconfig_types.go +++ b/api/v1alpha2/controllermanagerconfig_types.go @@ -104,8 +104,20 @@ type ControllerMetrics struct { // BindAddress is the TCP address that the controller should bind to // for serving prometheus metrics. // It can be set to "0" to disable the metrics serving. + // NOTE: This field is deprecated, please use DiagnosticsAddress field // +optional BindAddress string `json:"bindAddress,omitempty"` + + // DiagnosticsAddress is the TCP address that the controller should bind to + // for serving prometheus metric. + // It can be set to "0" to disable the metrics serving. + // +optional + DiagnosticsAddress string `json:"diagnosticsAddress,omitempty"` + + // InsecureDiagnostics indicates if insecure metrics serving should be enabled. + // If false, or not set, the diagnostics address will expose pprof endpoints too. + // +optional + InsecureDiagnostics bool `json:"insecureDiagnostics,omitempty"` } // ControllerHealth defines the health configs. diff --git a/config/crd/bases/operator.cluster.x-k8s.io_addonproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_addonproviders.yaml index 2449ff13e..4415b8e72 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_addonproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_addonproviders.yaml @@ -1440,7 +1440,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- @@ -2977,7 +2989,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- diff --git a/config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml index de0adbff2..5bccbc27f 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml @@ -1440,7 +1440,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- @@ -2977,7 +2989,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- diff --git a/config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml index c278a3e48..ab7dce97a 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml @@ -1441,7 +1441,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- @@ -2978,7 +2990,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- diff --git a/config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml index ee05932d8..a78488889 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml @@ -1440,7 +1440,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- @@ -2977,7 +2989,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- diff --git a/config/crd/bases/operator.cluster.x-k8s.io_infrastructureproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_infrastructureproviders.yaml index 5c211c2ff..1a2915b21 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_infrastructureproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_infrastructureproviders.yaml @@ -1441,7 +1441,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- @@ -2978,7 +2990,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- diff --git a/config/crd/bases/operator.cluster.x-k8s.io_ipamproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_ipamproviders.yaml index 77c4fa125..767bf006a 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_ipamproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_ipamproviders.yaml @@ -1440,7 +1440,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- @@ -2977,7 +2989,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- diff --git a/config/crd/bases/operator.cluster.x-k8s.io_runtimeextensionproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_runtimeextensionproviders.yaml index 3ced8a421..b912862f3 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_runtimeextensionproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_runtimeextensionproviders.yaml @@ -1442,7 +1442,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- @@ -2979,7 +2991,19 @@ spec: BindAddress is the TCP address that the controller should bind to for serving prometheus metrics. It can be set to "0" to disable the metrics serving. + NOTE: This field is deprecated, please use DiagnosticsAddress field type: string + diagnosticsAddress: + description: |- + DiagnosticsAddress is the TCP address that the controller should bind to + for serving prometheus metric. + It can be set to "0" to disable the metrics serving. + type: string + insecureDiagnostics: + description: |- + InsecureDiagnostics indicates if insecure metrics serving should be enabled. + If false, or not set, the diagnostics address will expose pprof endpoints too. + type: boolean type: object profilerAddress: description: |- diff --git a/internal/controller/component_customizer.go b/internal/controller/component_customizer.go index 2cb50858a..478afb63f 100644 --- a/internal/controller/component_customizer.go +++ b/internal/controller/component_customizer.go @@ -19,6 +19,7 @@ package controller import ( "fmt" "sort" + "strconv" "strings" "time" @@ -232,10 +233,17 @@ func customizeManagerContainer(mSpec *operatorv1.ManagerSpec, c *corev1.Containe c.Args = leaderElectionArgs(mSpec.LeaderElection, c.Args) } + // metrics if mSpec.Metrics.BindAddress != "" { c.Args = setArgs(c.Args, "--metrics-bind-addr", mSpec.Metrics.BindAddress) } + if mSpec.Metrics.DiagnosticsAddress != "" { + c.Args = setArgs(c.Args, "--diagnostics-address", mSpec.Metrics.DiagnosticsAddress) + } + + c.Args = setArgs(c.Args, "--insecure-diagnostics", strconv.FormatBool(mSpec.Metrics.InsecureDiagnostics)) + // webhooks if mSpec.Webhook.Host != "" { c.Args = setArgs(c.Args, "--webhook-host", mSpec.Webhook.Host)