diff --git a/charts/linkerd-control-plane/templates/podmonitor.yaml b/charts/linkerd-control-plane/templates/podmonitor.yaml index ba1bc0f9866fa..397b601eff9a1 100644 --- a/charts/linkerd-control-plane/templates/podmonitor.yaml +++ b/charts/linkerd-control-plane/templates/podmonitor.yaml @@ -38,6 +38,13 @@ spec: - __meta_kubernetes_pod_container_name action: replace targetLabel: component + {{- with $podMonitor.controller.extraRelabelings }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $podMonitor.controller.extraMetricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- if and $podMonitor.enabled $podMonitor.serviceMirror.enabled }} --- @@ -80,6 +87,13 @@ spec: - __meta_kubernetes_pod_container_name action: replace targetLabel: component + {{- with $podMonitor.serviceMirror.extraRelabelings }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $podMonitor.serviceMirror.extraMetricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- if and $podMonitor.enabled $podMonitor.proxy.enabled }} --- @@ -142,4 +156,11 @@ spec: regex: __tmp_pod_label_linkerd_io_(.+) - action: labelmap regex: __tmp_pod_label_(.+) + {{- with $podMonitor.proxy.extraRelabelings }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $podMonitor.proxy.extraMetricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} diff --git a/charts/linkerd-control-plane/values.yaml b/charts/linkerd-control-plane/values.yaml index 09a8cdb856f43..480ad3407e676 100644 --- a/charts/linkerd-control-plane/values.yaml +++ b/charts/linkerd-control-plane/values.yaml @@ -725,12 +725,22 @@ podMonitor: # -- Sets honorTimestamps for the control-plane PodMonitor endpoint. When set to false # Prometheus uses scrape time instead of exporter-provided timestamps. honorTimestamps: false + # -- Additional relabelings, appended after the relabelings the chart already sets + # on the control-plane PodMonitor endpoint + extraRelabelings: [] + # -- Metric relabelings to set on the control-plane PodMonitor endpoint + extraMetricRelabelings: [] serviceMirror: # -- Enables the creation of PodMonitor for the Service Mirror component enabled: true # -- Sets honorTimestamps for the Service Mirror PodMonitor endpoint. When set to false, # Prometheus uses scrape time instead of exporter-provided timestamps. honorTimestamps: false + # -- Additional relabelings, appended after the relabelings the chart already sets + # on the Service Mirror PodMonitor endpoint + extraRelabelings: [] + # -- Metric relabelings to set on the Service Mirror PodMonitor endpoint + extraMetricRelabelings: [] proxy: # -- Enables the creation of PodMonitor for the data-plane enabled: true @@ -738,6 +748,11 @@ podMonitor: # Prometheus uses scrape time instead of exporter-provided timestamps, # preventing duplicate timestamp drops in clusters with frequent pod restarts. honorTimestamps: false + # -- Additional relabelings, appended after the relabelings the chart already sets + # on the proxy PodMonitor endpoint + extraRelabelings: [] + # -- Metric relabelings to set on the proxy PodMonitor endpoint + extraMetricRelabelings: [] # Egress related configuration diff --git a/cli/cmd/testdata/install_controlplane_tracing_output.golden b/cli/cmd/testdata/install_controlplane_tracing_output.golden index 14f88fe00fa8a..734dfb851c8e3 100644 --- a/cli/cmd/testdata/install_controlplane_tracing_output.golden +++ b/cli/cmd/testdata/install_controlplane_tracing_output.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_custom_domain.golden b/cli/cmd/testdata/install_custom_domain.golden index e31a8ee0c1381..d6c420cf7c314 100644 --- a/cli/cmd/testdata/install_custom_domain.golden +++ b/cli/cmd/testdata/install_custom_domain.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_custom_registry.golden b/cli/cmd/testdata/install_custom_registry.golden index 0087373619fa5..64bad271d2be2 100644 --- a/cli/cmd/testdata/install_custom_registry.golden +++ b/cli/cmd/testdata/install_custom_registry.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_default.golden b/cli/cmd/testdata/install_default.golden index e31a8ee0c1381..d6c420cf7c314 100644 --- a/cli/cmd/testdata/install_default.golden +++ b/cli/cmd/testdata/install_default.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_default_override_dst_get_nets.golden b/cli/cmd/testdata/install_default_override_dst_get_nets.golden index 0e2d31b7ad36b..2d915a5fce14b 100644 --- a/cli/cmd/testdata/install_default_override_dst_get_nets.golden +++ b/cli/cmd/testdata/install_default_override_dst_get_nets.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_default_token.golden b/cli/cmd/testdata/install_default_token.golden index 507781f8ee75a..8fc929a919feb 100644 --- a/cli/cmd/testdata/install_default_token.golden +++ b/cli/cmd/testdata/install_default_token.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_gid_output.golden b/cli/cmd/testdata/install_gid_output.golden index 724b0afdab4c6..43bc981b9ba47 100755 --- a/cli/cmd/testdata/install_gid_output.golden +++ b/cli/cmd/testdata/install_gid_output.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_ha_output.golden b/cli/cmd/testdata/install_ha_output.golden index 9a40c95c67792..797aae616830c 100644 --- a/cli/cmd/testdata/install_ha_output.golden +++ b/cli/cmd/testdata/install_ha_output.golden @@ -657,6 +657,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -665,11 +667,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_ha_with_overrides_output.golden b/cli/cmd/testdata/install_ha_with_overrides_output.golden index 62610fda2def2..7833c2660aadc 100644 --- a/cli/cmd/testdata/install_ha_with_overrides_output.golden +++ b/cli/cmd/testdata/install_ha_with_overrides_output.golden @@ -657,6 +657,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -665,11 +667,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_heartbeat_disabled_output.golden b/cli/cmd/testdata/install_heartbeat_disabled_output.golden index 0c36d30ee7ced..a1911cff5f670 100644 --- a/cli/cmd/testdata/install_heartbeat_disabled_output.golden +++ b/cli/cmd/testdata/install_heartbeat_disabled_output.golden @@ -561,6 +561,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -569,11 +571,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_helm_control_plane_output.golden b/cli/cmd/testdata/install_helm_control_plane_output.golden index ac4620c922cd9..d42fd7be859d7 100644 --- a/cli/cmd/testdata/install_helm_control_plane_output.golden +++ b/cli/cmd/testdata/install_helm_control_plane_output.golden @@ -607,6 +607,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -615,11 +617,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_helm_control_plane_output_ha.golden b/cli/cmd/testdata/install_helm_control_plane_output_ha.golden index f590667ee225c..c7e52d238c670 100644 --- a/cli/cmd/testdata/install_helm_control_plane_output_ha.golden +++ b/cli/cmd/testdata/install_helm_control_plane_output_ha.golden @@ -634,6 +634,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -642,11 +644,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_helm_control_plane_output_ha_with_gid.golden b/cli/cmd/testdata/install_helm_control_plane_output_ha_with_gid.golden index 998db6ccf9556..5c68fd6be85dc 100755 --- a/cli/cmd/testdata/install_helm_control_plane_output_ha_with_gid.golden +++ b/cli/cmd/testdata/install_helm_control_plane_output_ha_with_gid.golden @@ -634,6 +634,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -642,11 +644,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_helm_output_ha_labels.golden b/cli/cmd/testdata/install_helm_output_ha_labels.golden index 3dec73707cf5c..cfccb0c11271b 100644 --- a/cli/cmd/testdata/install_helm_output_ha_labels.golden +++ b/cli/cmd/testdata/install_helm_output_ha_labels.golden @@ -638,6 +638,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -646,11 +648,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_helm_output_ha_namespace_selector.golden b/cli/cmd/testdata/install_helm_output_ha_namespace_selector.golden index 675a598369cb0..fd410d06eb4dd 100644 --- a/cli/cmd/testdata/install_helm_output_ha_namespace_selector.golden +++ b/cli/cmd/testdata/install_helm_output_ha_namespace_selector.golden @@ -629,6 +629,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -637,11 +639,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_no_init_container.golden b/cli/cmd/testdata/install_no_init_container.golden index 8fcecc277bcab..71d91abae4a05 100644 --- a/cli/cmd/testdata/install_no_init_container.golden +++ b/cli/cmd/testdata/install_no_init_container.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_proxy_ignores.golden b/cli/cmd/testdata/install_proxy_ignores.golden index 2477138ced9b5..323cd2405d252 100644 --- a/cli/cmd/testdata/install_proxy_ignores.golden +++ b/cli/cmd/testdata/install_proxy_ignores.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_tracing.golden b/cli/cmd/testdata/install_tracing.golden index 49fd8c9a185c6..b932c801e60fe 100644 --- a/cli/cmd/testdata/install_tracing.golden +++ b/cli/cmd/testdata/install_tracing.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/cli/cmd/testdata/install_values_file.golden b/cli/cmd/testdata/install_values_file.golden index f9ff3934d6e88..f64f0e4204af7 100644 --- a/cli/cmd/testdata/install_values_file.golden +++ b/cli/cmd/testdata/install_values_file.golden @@ -630,6 +630,8 @@ data: podMonitor: controller: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false namespaceSelector: | matchNames: @@ -638,11 +640,15 @@ data: enabled: false proxy: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false scrapeInterval: 10s scrapeTimeout: 10s serviceMirror: enabled: true + extraMetricRelabelings: [] + extraRelabelings: [] honorTimestamps: false policyController: logLevel: info diff --git a/pkg/charts/linkerd2/values.go b/pkg/charts/linkerd2/values.go index 0f7afdb51aaa8..5abad20c54c24 100644 --- a/pkg/charts/linkerd2/values.go +++ b/pkg/charts/linkerd2/values.go @@ -263,15 +263,19 @@ type ( // PodMonitorController contains the fields to configure the Prometheus Operator `PodMonitor` for the control-plane PodMonitorController struct { - Enabled bool `json:"enabled"` - NamespaceSelector string `json:"namespaceSelector"` - HonorTimestamps *bool `json:"honorTimestamps,omitempty"` + Enabled bool `json:"enabled"` + NamespaceSelector string `json:"namespaceSelector"` + HonorTimestamps *bool `json:"honorTimestamps,omitempty"` + ExtraRelabelings []interface{} `json:"extraRelabelings"` + ExtraMetricRelabelings []interface{} `json:"extraMetricRelabelings"` } // PodMonitorComponent contains the fields to configure the Prometheus Operator `PodMonitor` for other components PodMonitorComponent struct { - Enabled bool `json:"enabled"` - HonorTimestamps *bool `json:"honorTimestamps,omitempty"` + Enabled bool `json:"enabled"` + HonorTimestamps *bool `json:"honorTimestamps,omitempty"` + ExtraRelabelings []interface{} `json:"extraRelabelings"` + ExtraMetricRelabelings []interface{} `json:"extraMetricRelabelings"` } // PolicyController contains the fields to configure the policy controller container diff --git a/pkg/charts/linkerd2/values_test.go b/pkg/charts/linkerd2/values_test.go index ed6ac5d0d9300..c9a11259974c2 100644 --- a/pkg/charts/linkerd2/values_test.go +++ b/pkg/charts/linkerd2/values_test.go @@ -87,10 +87,22 @@ func TestNewValues(t *testing.T) { - {{ .Release.Namespace }} - linkerd-viz `, - HonorTimestamps: func() *bool { b := false; return &b }(), + HonorTimestamps: func() *bool { b := false; return &b }(), + ExtraRelabelings: []interface{}{}, + ExtraMetricRelabelings: []interface{}{}, + }, + ServiceMirror: &PodMonitorComponent{ + Enabled: true, + HonorTimestamps: func() *bool { b := false; return &b }(), + ExtraRelabelings: []interface{}{}, + ExtraMetricRelabelings: []interface{}{}, + }, + Proxy: &PodMonitorComponent{ + Enabled: true, + HonorTimestamps: func() *bool { b := false; return &b }(), + ExtraRelabelings: []interface{}{}, + ExtraMetricRelabelings: []interface{}{}, }, - ServiceMirror: &PodMonitorComponent{Enabled: true, HonorTimestamps: func() *bool { b := false; return &b }()}, - Proxy: &PodMonitorComponent{Enabled: true, HonorTimestamps: func() *bool { b := false; return &b }()}, }, DestinationController: &DestinationController{ MeshedHttp2ClientProtobuf: map[string]interface{}{