From 4677036a143ccab8d0e642554685718e9078b986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20=C4=8Cekrli=C4=87?= Date: Tue, 18 May 2021 22:58:53 +0200 Subject: [PATCH] Update: Add the possibility to add a Secret to the chart --- helm/mail/templates/secret.yaml | 15 +++++++++++++++ helm/mail/templates/statefulset.yaml | 4 ++++ helm/mail/values.yaml | 4 ++++ helm/test_5_secret.yml | 11 +++++++++++ 4 files changed, 34 insertions(+) create mode 100644 helm/mail/templates/secret.yaml create mode 100644 helm/test_5_secret.yml diff --git a/helm/mail/templates/secret.yaml b/helm/mail/templates/secret.yaml new file mode 100644 index 0000000..f5530a2 --- /dev/null +++ b/helm/mail/templates/secret.yaml @@ -0,0 +1,15 @@ +{{- $chart := "mail" -}} +{{- $fullName := include (print $chart ".fullname") . -}} +{{- $labels := include (print $chart ".labels") . -}} +{{- with .Values.secret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ $fullName }} + labels: + {{- $labels | nindent 4 }} +data: + {{- range $key, $value := . }} + {{ $key }}: {{ $value | b64enc | quote }} + {{- end }} +{{ end }} diff --git a/helm/mail/templates/statefulset.yaml b/helm/mail/templates/statefulset.yaml index 0f7f908..afb67bd 100644 --- a/helm/mail/templates/statefulset.yaml +++ b/helm/mail/templates/statefulset.yaml @@ -91,6 +91,10 @@ spec: envFrom: - configMapRef: name: {{ $fullName | quote }} + {{- with .Values.secret }} + - secretRef: + name: {{ $fullName | quote }} + {{- end }} {{ with .Values.extraEnv }}env: {{- toYaml . | nindent 12 }}{{ end }} volumeMounts: - mountPath: /var/spool/postfix diff --git a/helm/mail/values.yaml b/helm/mail/values.yaml index 9286382..9e4be96 100644 --- a/helm/mail/values.yaml +++ b/helm/mail/values.yaml @@ -68,6 +68,10 @@ container: postfix: securityContext: {} +# Define data which should be stored in a Secret +# (and shared with the pod as environment variables) +# secret: {} + config: general: {} # e.g. diff --git a/helm/test_5_secret.yml b/helm/test_5_secret.yml new file mode 100644 index 0000000..e0e4fe8 --- /dev/null +++ b/helm/test_5_secret.yml @@ -0,0 +1,11 @@ +autoscaling: + enabled: true + maxReplicas: 4 + +config: + general: + TZ: Europe/London + ALLOWED_SENDER_DOMAINS: example.org + +secret: + Hello: "World" \ No newline at end of file