From 4dac64a380b2d76b94055dc12f9f13ae819dcb59 Mon Sep 17 00:00:00 2001 From: Julio Chana Date: Sat, 28 Dec 2024 08:20:10 +0100 Subject: [PATCH] feat: Create secret to store credentials when provided (#5099) Signed-off-by: Julio Chana --- .../prometheus-rabbitmq-exporter/Chart.yaml | 2 +- .../templates/deployment.yaml | 10 +++++++-- .../templates/secret.yaml | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 charts/prometheus-rabbitmq-exporter/templates/secret.yaml diff --git a/charts/prometheus-rabbitmq-exporter/Chart.yaml b/charts/prometheus-rabbitmq-exporter/Chart.yaml index f34a2bd47669..50d5adf1680d 100644 --- a/charts/prometheus-rabbitmq-exporter/Chart.yaml +++ b/charts/prometheus-rabbitmq-exporter/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 description: Rabbitmq metrics exporter for prometheus name: prometheus-rabbitmq-exporter -version: 1.12.1 +version: 1.13.0 appVersion: v0.29.0 home: https://github.com/kbudde/rabbitmq_exporter sources: diff --git a/charts/prometheus-rabbitmq-exporter/templates/deployment.yaml b/charts/prometheus-rabbitmq-exporter/templates/deployment.yaml index 887364b2899e..69fb579c81ec 100644 --- a/charts/prometheus-rabbitmq-exporter/templates/deployment.yaml +++ b/charts/prometheus-rabbitmq-exporter/templates/deployment.yaml @@ -57,7 +57,10 @@ spec: key: "{{ .Values.rabbitmq.existingPasswordSecretKey }}" {{- else if .Values.rabbitmq.password }} - name: RABBIT_PASSWORD - value: {{ .Values.rabbitmq.password }} + valueFrom: + secretKeyRef: + name: {{ template "prometheus-rabbitmq-exporter.fullname" . }} + key: RABBIT_PASSWORD {{- end }} {{- if .Values.rabbitmq.existingUserSecret }} - name: RABBIT_USER @@ -67,7 +70,10 @@ spec: key: "{{ .Values.rabbitmq.existingUserSecretKey }}" {{- else if .Values.rabbitmq.user }} - name: RABBIT_USER - value: {{ .Values.rabbitmq.user }} + valueFrom: + secretKeyRef: + name: {{ template "prometheus-rabbitmq-exporter.fullname" . }} + key: RABBIT_USER {{- end }} {{- if .Values.rabbitmq.url }} - name: RABBIT_URL diff --git a/charts/prometheus-rabbitmq-exporter/templates/secret.yaml b/charts/prometheus-rabbitmq-exporter/templates/secret.yaml new file mode 100644 index 000000000000..c58c1ec75bd2 --- /dev/null +++ b/charts/prometheus-rabbitmq-exporter/templates/secret.yaml @@ -0,0 +1,22 @@ +{{- if or (and (.Values.rabbitmq.password) (not .Values.rabbitmq.existingPasswordSecret)) (and (.Values.rabbitmq.user) (not .Values.rabbitmq.existingUserSecret)) }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "prometheus-rabbitmq-exporter.fullname" . }} + labels: + app: {{ template "prometheus-rabbitmq-exporter.name" . }} + chart: {{ template "prometheus-rabbitmq-exporter.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + {{- if .Values.additionalLabels }} +{{ toYaml .Values.additionalLabels | indent 4 }} + {{- end }} +type: Opaque +data: + {{- if and (.Values.rabbitmq.password) (not .Values.rabbitmq.existingPasswordSecret) }} + RABBIT_PASSWORD: {{ .Values.rabbitmq.password | b64enc }} + {{- end }} + {{- if and (.Values.rabbitmq.user) (not .Values.rabbitmq.existingUserSecret) }} + RABBIT_USER: {{ .Values.rabbitmq.user | b64enc }} + {{- end }} +{{- end }}