From 0024f17d94d26090e45426d1f563c8309058861e Mon Sep 17 00:00:00 2001 From: Yi Jing Date: Thu, 9 Nov 2023 11:25:48 +0800 Subject: [PATCH] servicemonitor: crd judgement & changable label --- .../templates/redis-servicemonitor.yaml | 11 +++++++++++ charts/redis-operator/values.yaml | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/charts/redis-operator/templates/redis-servicemonitor.yaml b/charts/redis-operator/templates/redis-servicemonitor.yaml index 9ba771b..86268f4 100644 --- a/charts/redis-operator/templates/redis-servicemonitor.yaml +++ b/charts/redis-operator/templates/redis-servicemonitor.yaml @@ -1,3 +1,4 @@ +{{ if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" -}} {{- if eq .Values.serviceMonitor true }} --- apiVersion: monitoring.coreos.com/v1 @@ -9,6 +10,9 @@ metadata: app.kubernetes.io/vendor: kubesphere redis-operator: "true" env: production + {{- if .Values.customLabels.serviceMonitor.labels }} + {{- toYaml .Values.customLabels.serviceMonitor.labels | nindent 4 }} + {{- end }} spec: selector: matchLabels: @@ -30,6 +34,9 @@ metadata: app.kubernetes.io/vendor: kubesphere redis-operator: "true" env: production + {{- if .Values.customLabels.serviceMonitor.labels }} + {{- toYaml .Values.customLabels.serviceMonitor.labels | nindent 4 }} + {{- end }} spec: selector: matchLabels: @@ -51,6 +58,9 @@ metadata: app.kubernetes.io/vendor: kubesphere redis-operator: "true" env: production + {{- if .Values.customLabels.serviceMonitor.labels }} + {{- toYaml .Values.customLabels.serviceMonitor.labels | nindent 4 }} + {{- end }} spec: selector: matchLabels: @@ -62,3 +72,4 @@ spec: path: /metrics interval: 10s {{- end }} +{{ end }} \ No newline at end of file diff --git a/charts/redis-operator/values.yaml b/charts/redis-operator/values.yaml index cb80cf2..a95c33c 100644 --- a/charts/redis-operator/values.yaml +++ b/charts/redis-operator/values.yaml @@ -40,3 +40,7 @@ tolerations: [] affinity: {} serviceMonitor: true redisPasswordEncrypt: 0 + +customLabels: + serviceMonitor: + labels: