From cb3dcd7f1e0e6a152d110bcb776523856468e670 Mon Sep 17 00:00:00 2001 From: Philippe Dagenais Date: Fri, 17 May 2019 15:36:14 -0400 Subject: [PATCH] [stable/prometheus-mongodb-exporter] Add MONGODB_URI env variable secret (#13959) * Add MONGODB_URI env variable secret Signed-off-by: Dagenais, Philippe * Bump chart version Signed-off-by: Dagenais, Philippe * Use mongodb.uri value, remove the command line argument Signed-off-by: Dagenais, Philippe --- stable/prometheus-mongodb-exporter/Chart.yaml | 2 +- stable/prometheus-mongodb-exporter/README.md | 2 +- .../templates/deployment.yaml | 8 ++++++-- .../templates/secret.yaml | 12 ++++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 stable/prometheus-mongodb-exporter/templates/secret.yaml diff --git a/stable/prometheus-mongodb-exporter/Chart.yaml b/stable/prometheus-mongodb-exporter/Chart.yaml index 78ac4aec32..14539bafcb 100644 --- a/stable/prometheus-mongodb-exporter/Chart.yaml +++ b/stable/prometheus-mongodb-exporter/Chart.yaml @@ -13,4 +13,4 @@ maintainers: name: prometheus-mongodb-exporter sources: - https://github.com/percona/mongodb_exporter -version: 2.0.1 +version: 2.1.0 diff --git a/stable/prometheus-mongodb-exporter/README.md b/stable/prometheus-mongodb-exporter/README.md index 85113e5da6..59c5d1e5de 100644 --- a/stable/prometheus-mongodb-exporter/README.md +++ b/stable/prometheus-mongodb-exporter/README.md @@ -16,7 +16,7 @@ This command deploys the MongoDB Exporter with the default configuration. The [c ## Using the Chart To use the chart, ensure the `mongodb.uri` is populated with a valid [MongoDB URI](https://docs.mongodb.com/manual/reference/connection-string). -If the MongoDB server requires authentication, credentials should be populated in the connection string as well. The MongoDB Exporter supports +If the MongoDB server requires authentication, credentials should be populated in the connection string as well. The MongoDB Exporter supports connecting to either a MongoDB replica set member, shard, or standalone instance. The chart comes with a ServiceMonitor for use with the [Prometheus Operator](https://github.com/helm/charts/tree/master/stable/prometheus-operator). diff --git a/stable/prometheus-mongodb-exporter/templates/deployment.yaml b/stable/prometheus-mongodb-exporter/templates/deployment.yaml index 63eb660cd4..a150d005df 100644 --- a/stable/prometheus-mongodb-exporter/templates/deployment.yaml +++ b/stable/prometheus-mongodb-exporter/templates/deployment.yaml @@ -25,8 +25,13 @@ spec: spec: containers: - name: mongodb-exporter - {{- if .Values.env }} env: + - name: MONGODB_URI + valueFrom: + secretKeyRef: + name: {{ include "prometheus-mongodb-exporter.fullname" . }} + key: mongodb-uri + {{- if .Values.env }} {{- range $key, $value := .Values.env }} - name: "{{ $key }}" value: "{{ $value }}" @@ -35,7 +40,6 @@ spec: image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} args: - - --mongodb.uri={{ required "A MongoDB URI is required" .Values.mongodb.uri }} - --web.listen-address={{ printf ":%s" .Values.port }} {{- toYaml .Values.extraArgs | nindent 8 }} ports: diff --git a/stable/prometheus-mongodb-exporter/templates/secret.yaml b/stable/prometheus-mongodb-exporter/templates/secret.yaml new file mode 100644 index 0000000000..9a7ca8a299 --- /dev/null +++ b/stable/prometheus-mongodb-exporter/templates/secret.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "prometheus-mongodb-exporter.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "prometheus-mongodb-exporter.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + helm.sh/chart: {{ include "prometheus-mongodb-exporter.chart" . }} +type: Opaque +data: + mongodb-uri: {{ required "A MongoDB URI is required" .Values.mongodb.uri | b64enc }}