From 9c1ee0146de22df233557f0fc3c1d8e21640d430 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Fri, 12 May 2023 18:50:44 +0200 Subject: [PATCH 1/2] Add: Custom labels for ServiceMonitor resource Signed-off-by: Nicolas Lamirault --- charts/descheduler/README.md | 1 + charts/descheduler/templates/servicemonitor.yaml | 3 +++ charts/descheduler/values.yaml | 3 +++ 3 files changed, 7 insertions(+) diff --git a/charts/descheduler/README.md b/charts/descheduler/README.md index 923c98aaae..71f17e572b 100644 --- a/charts/descheduler/README.md +++ b/charts/descheduler/README.md @@ -75,6 +75,7 @@ The following table lists the configurable parameters of the _descheduler_ chart | `service.enabled` | If `true`, create a service for deployment | `false` | | `serviceMonitor.enabled` | If `true`, create a ServiceMonitor for deployment | `false` | | `serviceMonitor.namespace` | The namespace where Prometheus expects to find service monitors | `nil` | +| `serviceMonitor.additionalLabels` | Add custom labels to the ServiceMonitor resource | `{}` | | `serviceMonitor.interval` | The scrape interval. If not set, the Prometheus default scrape interval is used | `nil` | | `serviceMonitor.honorLabels` | Keeps the scraped data's labels when labels are on collisions with target labels. | `true` | | `serviceMonitor.insecureSkipVerify` | Skip TLS certificate validation when scraping | `true` | diff --git a/charts/descheduler/templates/servicemonitor.yaml b/charts/descheduler/templates/servicemonitor.yaml index 800475076e..33267276be 100644 --- a/charts/descheduler/templates/servicemonitor.yaml +++ b/charts/descheduler/templates/servicemonitor.yaml @@ -7,6 +7,9 @@ metadata: namespace: {{ .Values.serviceMonitor.namespace | default .Release.Namespace }} labels: {{- include "descheduler.labels" . | nindent 4 }} + {{- if .Values.serviceMonitor.additionalLabels }} + {{ toYaml .Values.serviceMonitor.additionalLabels }} + {{- end }} spec: jobLabel: jobLabel namespaceSelector: diff --git a/charts/descheduler/values.yaml b/charts/descheduler/values.yaml index c4a8e0e04d..d3a068bbf1 100644 --- a/charts/descheduler/values.yaml +++ b/charts/descheduler/values.yaml @@ -177,6 +177,9 @@ serviceMonitor: enabled: false # The namespace where Prometheus expects to find service monitors. # namespace: "" + # Add custom labels to the ServiceMonitor resource + additionalLabels: {} + # prometheus: kube-prometheus-stack interval: "" # honorLabels: true insecureSkipVerify: true From 3a48633fe606f20af1c5fc7e3863d1282eeff31a Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Wed, 31 May 2023 10:52:28 +0200 Subject: [PATCH 2/2] Fix: indentation Signed-off-by: Nicolas Lamirault --- charts/descheduler/templates/servicemonitor.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/descheduler/templates/servicemonitor.yaml b/charts/descheduler/templates/servicemonitor.yaml index 33267276be..25d980468b 100644 --- a/charts/descheduler/templates/servicemonitor.yaml +++ b/charts/descheduler/templates/servicemonitor.yaml @@ -8,7 +8,7 @@ metadata: labels: {{- include "descheduler.labels" . | nindent 4 }} {{- if .Values.serviceMonitor.additionalLabels }} - {{ toYaml .Values.serviceMonitor.additionalLabels }} + {{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }} {{- end }} spec: jobLabel: jobLabel