From 1b20583cc742dd49c24e6f7e1ae65c3f8e4c518f Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Tue, 14 Sep 2021 16:59:41 +0200 Subject: [PATCH] [kube-prometheus-stack] Use prometheus-node-exporter.namespaceOverride when set Signed-off-by: Mathieu Parent --- charts/kube-prometheus-stack/Chart.yaml | 2 +- charts/kube-prometheus-stack/templates/_helpers.tpl | 11 +++++++++++ .../exporters/node-exporter/servicemonitor.yaml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/charts/kube-prometheus-stack/Chart.yaml b/charts/kube-prometheus-stack/Chart.yaml index 9598cb99d356..d6a571ea3d44 100644 --- a/charts/kube-prometheus-stack/Chart.yaml +++ b/charts/kube-prometheus-stack/Chart.yaml @@ -18,7 +18,7 @@ name: kube-prometheus-stack sources: - https://github.com/prometheus-community/helm-charts - https://github.com/prometheus-operator/kube-prometheus -version: 18.0.9 +version: 18.0.10 appVersion: 0.50.0 kubeVersion: ">=1.16.0-0" home: https://github.com/prometheus-operator/kube-prometheus diff --git a/charts/kube-prometheus-stack/templates/_helpers.tpl b/charts/kube-prometheus-stack/templates/_helpers.tpl index e911fe0a81ca..5b30785781e7 100644 --- a/charts/kube-prometheus-stack/templates/_helpers.tpl +++ b/charts/kube-prometheus-stack/templates/_helpers.tpl @@ -118,6 +118,17 @@ Use the kube-state-metrics namespace override for multi-namespace deployments in {{- end -}} {{- end -}} +{{/* +Use the prometheus-node-exporter namespace override for multi-namespace deployments in combined charts +*/}} +{{- define "prometheus-node-exporter.namespace" -}} + {{- if index .Values "prometheus-node-exporter" "namespaceOverride" -}} + {{- index .Values "prometheus-node-exporter" "namespaceOverride" -}} + {{- else -}} + {{- .Release.Namespace -}} + {{- end -}} +{{- end -}} + {{/* Allow KubeVersion to be overridden. */}} {{- define "kube-prometheus-stack.kubeVersion" -}} {{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride -}} diff --git a/charts/kube-prometheus-stack/templates/exporters/node-exporter/servicemonitor.yaml b/charts/kube-prometheus-stack/templates/exporters/node-exporter/servicemonitor.yaml index 5615ba7e878c..396de3b1236b 100644 --- a/charts/kube-prometheus-stack/templates/exporters/node-exporter/servicemonitor.yaml +++ b/charts/kube-prometheus-stack/templates/exporters/node-exporter/servicemonitor.yaml @@ -3,7 +3,7 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: {{ template "kube-prometheus-stack.fullname" . }}-node-exporter - namespace: {{ template "kube-prometheus-stack.namespace" . }} + namespace: {{ template "prometheus-node-exporter.namespace" . }} labels: app: {{ template "kube-prometheus-stack.name" . }}-node-exporter {{ include "kube-prometheus-stack.labels" . | indent 4 }}