From 378da322e281a91947686c750d597f3281bd8446 Mon Sep 17 00:00:00 2001 From: Firas Mosbehi Date: Fri, 6 Mar 2026 10:36:23 +0100 Subject: [PATCH] prometheus-cloudwatch-exporter: add commonLabels support Signed-off-by: Firas Mosbehi --- charts/prometheus-cloudwatch-exporter/Chart.yaml | 2 +- .../templates/clusterrole.yaml | 3 +++ .../templates/clusterrolebinding.yaml | 3 +++ .../templates/configmap.yaml | 3 +++ .../templates/deployment.yaml | 6 ++++++ .../templates/ingress.yaml | 3 +++ charts/prometheus-cloudwatch-exporter/templates/pdb.yaml | 3 +++ .../templates/prometheusrule.yaml | 9 +++++++-- .../templates/secrets.yaml | 3 +++ .../templates/service.yaml | 3 +++ .../templates/serviceaccount.yaml | 3 +++ .../templates/servicemonitor.yaml | 9 +++++++-- charts/prometheus-cloudwatch-exporter/values.yaml | 3 +++ 13 files changed, 48 insertions(+), 5 deletions(-) diff --git a/charts/prometheus-cloudwatch-exporter/Chart.yaml b/charts/prometheus-cloudwatch-exporter/Chart.yaml index 93f232c499af..d519a56a9ed1 100644 --- a/charts/prometheus-cloudwatch-exporter/Chart.yaml +++ b/charts/prometheus-cloudwatch-exporter/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.16.0" description: A Helm chart for prometheus cloudwatch-exporter name: prometheus-cloudwatch-exporter -version: 0.28.1 +version: 0.28.2 home: https://github.com/prometheus/cloudwatch_exporter sources: - https://github.com/prometheus/cloudwatch_exporter diff --git a/charts/prometheus-cloudwatch-exporter/templates/clusterrole.yaml b/charts/prometheus-cloudwatch-exporter/templates/clusterrole.yaml index 9afa3037a4e2..167331704ce9 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/clusterrole.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/clusterrole.yaml @@ -8,6 +8,9 @@ metadata: chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} + {{- with .Values.commonLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} rules: - apiGroups: [""] resources: ["secrets","configmap"] diff --git a/charts/prometheus-cloudwatch-exporter/templates/clusterrolebinding.yaml b/charts/prometheus-cloudwatch-exporter/templates/clusterrolebinding.yaml index d9708e7ab6f3..770350dc7bbb 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/clusterrolebinding.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/clusterrolebinding.yaml @@ -8,6 +8,9 @@ metadata: chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} + {{- with .Values.commonLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} subjects: - kind: ServiceAccount name: {{ template "prometheus-cloudwatch-exporter.serviceAccountName" . }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/configmap.yaml b/charts/prometheus-cloudwatch-exporter/templates/configmap.yaml index fa2699df3de6..85c980f043ed 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/configmap.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/configmap.yaml @@ -8,6 +8,9 @@ metadata: chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} + {{- with .Values.commonLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} data: config.yml: | {{ tpl .Values.config . | nindent 4 }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/deployment.yaml b/charts/prometheus-cloudwatch-exporter/templates/deployment.yaml index 35544066f49a..72047ca059ee 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/deployment.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/deployment.yaml @@ -8,6 +8,9 @@ metadata: chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} + {{- with .Values.commonLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} {{- with .Values.deployment.labels }} {{- toYaml . | nindent 4 }} {{- end }} @@ -26,6 +29,9 @@ spec: labels: app: {{ template "prometheus-cloudwatch-exporter.name" . }} release: {{ .Release.Name }} + {{- with .Values.commonLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} {{- if .Values.pod.labels }} {{ toYaml .Values.pod.labels | indent 8 }} {{- end }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/ingress.yaml b/charts/prometheus-cloudwatch-exporter/templates/ingress.yaml index c58cf427e465..6c57be3403ae 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/ingress.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/ingress.yaml @@ -13,6 +13,9 @@ metadata: chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} +{{- with .Values.commonLabels }} +{{ toYaml . | indent 4 }} +{{- end }} {{- if .Values.ingress.labels }} {{ toYaml .Values.ingress.labels | indent 4 }} {{- end }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/pdb.yaml b/charts/prometheus-cloudwatch-exporter/templates/pdb.yaml index 7a88ca5c6ed1..c7c00fd047a1 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/pdb.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/pdb.yaml @@ -9,6 +9,9 @@ metadata: chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} + {{- with .Values.commonLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: {{- if .Values.podDisruptionBudget.minAvailable }} minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/prometheusrule.yaml b/charts/prometheus-cloudwatch-exporter/templates/prometheusrule.yaml index e0c0b8e44ce9..22da00339f73 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/prometheusrule.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/prometheusrule.yaml @@ -3,9 +3,14 @@ apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: -{{- if .Values.prometheusRule.labels }} +{{- if or .Values.prometheusRule.labels .Values.commonLabels }} labels: -{{ toYaml .Values.prometheusRule.labels | indent 4}} + {{- with .Values.commonLabels }} +{{ toYaml . | indent 4 }} + {{- end }} + {{- with .Values.prometheusRule.labels }} +{{ toYaml . | indent 4 }} + {{- end }} {{- end }} name: {{ $fullName }} {{- if .Values.prometheusRule.namespace }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/secrets.yaml b/charts/prometheus-cloudwatch-exporter/templates/secrets.yaml index 7309b4d4fbe6..f9ddd13c6452 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/secrets.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/secrets.yaml @@ -9,6 +9,9 @@ metadata: chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} heritage: {{ .Release.Service }} release: {{ .Release.Name }} + {{- with .Values.commonLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} type: Opaque data: {{ if .Values.aws.aws_access_key_id }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/service.yaml b/charts/prometheus-cloudwatch-exporter/templates/service.yaml index 6fb1b125475d..5499980ba224 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/service.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/service.yaml @@ -10,6 +10,9 @@ metadata: chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} +{{- with .Values.commonLabels }} +{{ toYaml . | indent 4 }} +{{- end }} {{- if .Values.service.labels }} {{ toYaml .Values.service.labels | indent 4 }} {{- end }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/serviceaccount.yaml b/charts/prometheus-cloudwatch-exporter/templates/serviceaccount.yaml index 7eb7cf75ed7e..6579d38d708b 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/serviceaccount.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/serviceaccount.yaml @@ -10,6 +10,9 @@ metadata: chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" + {{- with .Values.commonLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} {{- if .Values.serviceAccount.annotations }} annotations: {{ toYaml .Values.serviceAccount.annotations | nindent 4 }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/servicemonitor.yaml b/charts/prometheus-cloudwatch-exporter/templates/servicemonitor.yaml index ed9234f34fa0..3a4cd67cca19 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/servicemonitor.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/servicemonitor.yaml @@ -2,9 +2,14 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: -{{- if .Values.serviceMonitor.labels }} +{{- if or .Values.serviceMonitor.labels .Values.commonLabels }} labels: -{{ toYaml .Values.serviceMonitor.labels | indent 4}} + {{- with .Values.commonLabels }} +{{ toYaml . | indent 4 }} + {{- end }} + {{- with .Values.serviceMonitor.labels }} +{{ toYaml . | indent 4 }} + {{- end }} {{- end }} name: {{ template "prometheus-cloudwatch-exporter.fullname" . }} {{- if .Values.serviceMonitor.namespace }} diff --git a/charts/prometheus-cloudwatch-exporter/values.yaml b/charts/prometheus-cloudwatch-exporter/values.yaml index 2353ea73568a..c7a897276cae 100644 --- a/charts/prometheus-cloudwatch-exporter/values.yaml +++ b/charts/prometheus-cloudwatch-exporter/values.yaml @@ -44,6 +44,9 @@ deployment: labels: {} annotations: {} +# Common labels to attach to all resources +commonLabels: {} + # Extra environment variables extraEnv: # - name: foo