From f42a0ff438bbe39542d55e5269ebc6d36c2c899b Mon Sep 17 00:00:00 2001 From: lou-lan Date: Thu, 28 Nov 2024 20:15:15 +0800 Subject: [PATCH] Add labels from global.commonLabels and prometheus.serviceMonitor.labels if defined Signed-off-by: lou-lan --- charts/spiderpool/templates/servicemonitor.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/charts/spiderpool/templates/servicemonitor.yaml b/charts/spiderpool/templates/servicemonitor.yaml index 1efa34623..4e682105a 100644 --- a/charts/spiderpool/templates/servicemonitor.yaml +++ b/charts/spiderpool/templates/servicemonitor.yaml @@ -5,6 +5,12 @@ metadata: name: {{ .Values.spiderpoolAgent.name | trunc 63 | trimSuffix "-" }} namespace: {{ default .Release.Namespace .Values.spiderpoolAgent.prometheus.serviceMonitor.namespace }} labels: + {{- if .Values.global.commonLabels }} + {{- include "tplvalues.render" ( dict "value" .Values.global.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.spiderpoolAgent.prometheus.serviceMonitor.labels }} + {{- include "tplvalues.render" ( dict "value" .Values.grafanaDashboard.labels "context" $ ) | nindent 4 }} + {{- end }} {{- if or .Values.global.commonAnnotations .Values.spiderpoolAgent.prometheus.serviceMonitor.annotations }} annotations: {{- if .Values.global.commonAnnotations }} @@ -36,6 +42,13 @@ kind: ServiceMonitor metadata: name: {{ .Values.spiderpoolController.name | trunc 63 | trimSuffix "-" }} namespace: {{ default .Release.Namespace .Values.spiderpoolController.prometheus.serviceMonitor.namespace }} + labels: + {{- if .Values.global.commonLabels }} + {{- include "tplvalues.render" ( dict "value" .Values.global.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.spiderpoolController.prometheus.serviceMonitor.labels }} + {{- include "tplvalues.render" ( dict "value" .Values.grafanaDashboard.labels "context" $ ) | nindent 4 }} + {{- end }} {{- if or .Values.global.commonAnnotations .Values.spiderpoolController.prometheus.serviceMonitor.annotations }} annotations: {{- if .Values.global.commonAnnotations }}