From b27c5cbe82ca332371905df0e8203f616230fdc8 Mon Sep 17 00:00:00 2001 From: Alexander Katsyuba Date: Mon, 18 Nov 2019 16:20:19 +0100 Subject: [PATCH] [stable/prometheus-node-exporter] Override of namespace Signed-off-by: Alexander Katsyuba --- stable/prometheus-node-exporter/Chart.yaml | 2 +- stable/prometheus-node-exporter/README.md | 1 + .../prometheus-node-exporter/templates/_helpers.tpl | 11 +++++++++++ .../prometheus-node-exporter/templates/daemonset.yaml | 1 + .../prometheus-node-exporter/templates/endpoints.yaml | 3 ++- .../prometheus-node-exporter/templates/monitor.yaml | 1 + .../templates/psp-clusterrole.yaml | 3 ++- .../templates/psp-clusterrolebinding.yaml | 3 ++- stable/prometheus-node-exporter/templates/psp.yaml | 3 ++- .../prometheus-node-exporter/templates/service.yaml | 1 + .../templates/serviceaccount.yaml | 7 ++++--- stable/prometheus-node-exporter/values.yaml | 4 ++++ 12 files changed, 32 insertions(+), 8 deletions(-) diff --git a/stable/prometheus-node-exporter/Chart.yaml b/stable/prometheus-node-exporter/Chart.yaml index 1cb9e625a911..dcde2454a13e 100644 --- a/stable/prometheus-node-exporter/Chart.yaml +++ b/stable/prometheus-node-exporter/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 0.18.1 description: A Helm chart for prometheus node-exporter name: prometheus-node-exporter -version: 1.7.3 +version: 1.7.4 home: /~https://github.com/prometheus/node_exporter/ sources: - /~https://github.com/prometheus/node_exporter/ diff --git a/stable/prometheus-node-exporter/README.md b/stable/prometheus-node-exporter/README.md index f5cbd8b86ce4..2ebf97775e7f 100644 --- a/stable/prometheus-node-exporter/README.md +++ b/stable/prometheus-node-exporter/README.md @@ -67,6 +67,7 @@ The following table lists the configurable parameters of the Node Exporter chart | `prometheus.monitor.namespace` | namespace where servicemonitor resource should be created | `the same namespace as prometheus node exporter` | | | `prometheus.monitor.scrapeTimeout` | Timeout after which the scrape is ended | `10s` | | | `configmaps` | Allow mounting additional configmaps. | `[]` | | +| `namespaceOverride` | Override the deployment namespace | `""` (`Release.Namespace`) | | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, diff --git a/stable/prometheus-node-exporter/templates/_helpers.tpl b/stable/prometheus-node-exporter/templates/_helpers.tpl index 4f0e2dfe9119..e8260688f08f 100644 --- a/stable/prometheus-node-exporter/templates/_helpers.tpl +++ b/stable/prometheus-node-exporter/templates/_helpers.tpl @@ -53,3 +53,14 @@ Create the name of the service account to use {{ default "default" .Values.serviceAccount.name }} {{- end -}} {{- end -}} + +{{/* +Allow the release namespace to be overridden for multi-namespace deployments in combined charts +*/}} +{{- define "prometheus-node-exporter.namespace" -}} + {{- if .Values.namespaceOverride -}} + {{- .Values.namespaceOverride -}} + {{- else -}} + {{- .Release.Namespace -}} + {{- end -}} +{{- end -}} diff --git a/stable/prometheus-node-exporter/templates/daemonset.yaml b/stable/prometheus-node-exporter/templates/daemonset.yaml index 0cbc2cc89bd8..56306a641a18 100644 --- a/stable/prometheus-node-exporter/templates/daemonset.yaml +++ b/stable/prometheus-node-exporter/templates/daemonset.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: DaemonSet metadata: name: {{ template "prometheus-node-exporter.fullname" . }} + namespace: {{ template "prometheus-node-exporter.namespace" . }} labels: {{ include "prometheus-node-exporter.labels" . | indent 4 }} spec: selector: diff --git a/stable/prometheus-node-exporter/templates/endpoints.yaml b/stable/prometheus-node-exporter/templates/endpoints.yaml index 4c5c75fa9d4a..8daaeaaff1f6 100644 --- a/stable/prometheus-node-exporter/templates/endpoints.yaml +++ b/stable/prometheus-node-exporter/templates/endpoints.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: Endpoints metadata: name: {{ template "prometheus-node-exporter.fullname" . }} + namespace: {{ template "prometheus-node-exporter.namespace" . }} labels: {{ include "prometheus-node-exporter.labels" . | indent 4 }} subsets: @@ -14,4 +15,4 @@ subsets: - name: metrics port: 9100 protocol: TCP -{{- end }} \ No newline at end of file +{{- end }} diff --git a/stable/prometheus-node-exporter/templates/monitor.yaml b/stable/prometheus-node-exporter/templates/monitor.yaml index 04f0e13e0cd7..f92fae8a701e 100644 --- a/stable/prometheus-node-exporter/templates/monitor.yaml +++ b/stable/prometheus-node-exporter/templates/monitor.yaml @@ -3,6 +3,7 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: {{ template "prometheus-node-exporter.fullname" . }} + namespace: {{ template "prometheus-node-exporter.namespace" . }} labels: {{ include "prometheus-node-exporter.labels" . | indent 4 }} {{- if .Values.prometheus.monitor.additionalLabels }} {{ toYaml .Values.prometheus.monitor.additionalLabels | indent 4 }} diff --git a/stable/prometheus-node-exporter/templates/psp-clusterrole.yaml b/stable/prometheus-node-exporter/templates/psp-clusterrole.yaml index b22027c26436..9ce344425ab3 100644 --- a/stable/prometheus-node-exporter/templates/psp-clusterrole.yaml +++ b/stable/prometheus-node-exporter/templates/psp-clusterrole.yaml @@ -3,8 +3,9 @@ kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: - labels: {{ include "prometheus-node-exporter.labels" . | indent 4 }} name: psp-{{ template "prometheus-node-exporter.fullname" . }} + namespace: {{ template "prometheus-node-exporter.namespace" . }} + labels: {{ include "prometheus-node-exporter.labels" . | indent 4 }} rules: - apiGroups: ['extensions'] resources: ['podsecuritypolicies'] diff --git a/stable/prometheus-node-exporter/templates/psp-clusterrolebinding.yaml b/stable/prometheus-node-exporter/templates/psp-clusterrolebinding.yaml index 94d2ac2b671a..ce17bf245672 100644 --- a/stable/prometheus-node-exporter/templates/psp-clusterrolebinding.yaml +++ b/stable/prometheus-node-exporter/templates/psp-clusterrolebinding.yaml @@ -3,8 +3,9 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - labels: {{ include "prometheus-node-exporter.labels" . | indent 4 }} name: psp-{{ template "prometheus-node-exporter.fullname" . }} + namespace: {{ template "prometheus-node-exporter.namespace" . }} + labels: {{ include "prometheus-node-exporter.labels" . | indent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/stable/prometheus-node-exporter/templates/psp.yaml b/stable/prometheus-node-exporter/templates/psp.yaml index 05e6ee2e4585..f00506c98000 100644 --- a/stable/prometheus-node-exporter/templates/psp.yaml +++ b/stable/prometheus-node-exporter/templates/psp.yaml @@ -3,8 +3,9 @@ apiVersion: policy/v1beta1 kind: PodSecurityPolicy metadata: - labels: {{ include "prometheus-node-exporter.labels" . | indent 4 }} name: {{ template "prometheus-node-exporter.fullname" . }} + namespace: {{ template "prometheus-node-exporter.namespace" . }} + labels: {{ include "prometheus-node-exporter.labels" . | indent 4 }} spec: privileged: false # Required to prevent escalations to root. diff --git a/stable/prometheus-node-exporter/templates/service.yaml b/stable/prometheus-node-exporter/templates/service.yaml index cffe547b10a2..b0a447fe3168 100644 --- a/stable/prometheus-node-exporter/templates/service.yaml +++ b/stable/prometheus-node-exporter/templates/service.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: {{ template "prometheus-node-exporter.fullname" . }} + namespace: {{ template "prometheus-node-exporter.namespace" . }} {{- if .Values.service.annotations }} annotations: {{ toYaml .Values.service.annotations | indent 4 }} diff --git a/stable/prometheus-node-exporter/templates/serviceaccount.yaml b/stable/prometheus-node-exporter/templates/serviceaccount.yaml index b70745aa6f82..bd1c223b4616 100644 --- a/stable/prometheus-node-exporter/templates/serviceaccount.yaml +++ b/stable/prometheus-node-exporter/templates/serviceaccount.yaml @@ -4,12 +4,13 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ template "prometheus-node-exporter.serviceAccountName" . }} + namespace: {{ template "prometheus-node-exporter.namespace" . }} labels: app: {{ template "prometheus-node-exporter.name" . }} - chart: {{ template "prometheus-node-exporter.chart" . }} + chart: {{ template "prometheus-node-exporter.chart" . }} release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" -imagePullSecrets: +imagePullSecrets: {{ toYaml .Values.serviceAccount.imagePullSecrets | indent 2 }} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/stable/prometheus-node-exporter/values.yaml b/stable/prometheus-node-exporter/values.yaml index 900111cc926d..cf7936735f2c 100644 --- a/stable/prometheus-node-exporter/values.yaml +++ b/stable/prometheus-node-exporter/values.yaml @@ -105,3 +105,7 @@ extraHostVolumeMounts: [] configmaps: [] # - name: # mountPath: + +## Override the deployment namespace +## +namespaceOverride: ""