Skip to content

Commit fab1b33

Browse files
committed
Fix for #83: Add the possibility to mount files from secret
1 parent 331e258 commit fab1b33

14 files changed

+51
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ Chart configuration is as follows:
490490
| `config.postfix` | `{}` | Key-value list of general postfix options, e.g. `myhostname: "demo"` |
491491
| `config.opendkim` | `{}` | Key-value list of general OpenDKIM options, e.g. `RequireSafeKeys: "yes"` |
492492
| `secret` | `{}` | Key-value list of environment variables to be shared with Postfix / OpenDKIM as secrets |
493+
| `mountSecret.enabled` | `false` | Create a folder with contents of the secret in the pod's container |
494+
| `mountSecret.path` | `/var/lib/secret` | Where to mount secret data |
495+
| `mountSecret.data` | `{}` | Key-value list of files to be mount into the container |
493496
| `persistence.enabled` | `true` | Persist Postfix's queue on disk |
494497
| `persistence.accessModes` | `[ 'ReadWriteOnce' ]` | Access mode |
495498
| `persistence.existingClaim` | `""` | Provide an existing `PersistentVolumeClaim`, the value is evaluated as a template. |
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if .Values.mountSecret.enabled -}}
2+
{{- $chart := "mail" -}}
3+
{{- $fullName := include (print $chart ".fullname") . -}}
4+
{{- $labels := include (print $chart ".labels") . -}}
5+
{{- with .Values.mountSecret.data }}
6+
apiVersion: v1
7+
kind: Secret
8+
metadata:
9+
name: {{ $fullName }}-mount
10+
labels:
11+
{{- $labels | nindent 4 }}
12+
data:
13+
{{- range $key, $value := . }}
14+
{{ $key }}: {{ $value | b64enc | quote }}
15+
{{- end }}
16+
{{ end }}
17+
{{- end -}}

helm/mail/templates/statefulset.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ spec:
105105
readOnly: true
106106
subPath: _enable_tls.sh
107107
{{- end }}
108+
{{- if .Values.mountSecret.enabled }}
109+
- name: mount-secret
110+
mountPath: {{ .Values.mountSecret.path }}
111+
readOnly: true
112+
{{- end }}
108113
{{- if .Values.extraVolumeMounts }}{{- toYaml .Values.extraVolumeMounts | nindent 12 }}{{ end }}
109114
resources: {{ toYaml .Values.resources | nindent 12 }}
110115
{{- if .Values.extraContainers }}
@@ -135,6 +140,11 @@ spec:
135140
- name: {{ $fullName }}
136141
emptyDir: {}
137142
{{- end }}
143+
{{- if .Values.mountSecret.enabled }}
144+
- name: mount-secret
145+
secret:
146+
secretName: {{ $fullName }}-mount
147+
{{- end }}
138148
{{- if .Values.extraVolumes }}{{- toYaml .Values.extraVolumes | nindent 8 }}{{ end }}
139149
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
140150
volumeClaimTemplates:
@@ -145,7 +155,7 @@ spec:
145155
accessModes: {{- toYaml .Values.persistence.accessModes | nindent 10 }}
146156
{{- if (eq "-" .Values.persistence.storageClass) }}
147157
storageClassName: ""
148-
{{- end }}{{- if .Values.persistence.storageClass }}
158+
{{- else if .Values.persistence.storageClass }}
149159
storageClassName: "{{ .Values.persistence.storageClass }}"
150160
{{- end }}
151161
resources:

helm/mail/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ certs:
9090
# hello: world
9191
secret: {}
9292

93+
# Define a secret which should be deployed together with the
94+
# chart amd mounted into a specific directory in the pod.
95+
mountSecret:
96+
enabled: false
97+
path: /var/lib/secret
98+
data: {}
99+
# e.g.
100+
# dkim-private: |
101+
# -----BEGIN RSA PRIVATE KEY-----
102+
# < redacted >
103+
# -----END RSA PRIVATE KEY-----
104+
93105
config:
94106
general: {}
95107
# e.g.

0 commit comments

Comments
 (0)