Skip to content

Commit

Permalink
Fix for bokysan#83: Add the possibility to mount files from secret
Browse files Browse the repository at this point in the history
  • Loading branch information
bokysan committed Aug 22, 2021
1 parent 331e258 commit fab1b33
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@ Chart configuration is as follows:
| `config.postfix` | `{}` | Key-value list of general postfix options, e.g. `myhostname: "demo"` |
| `config.opendkim` | `{}` | Key-value list of general OpenDKIM options, e.g. `RequireSafeKeys: "yes"` |
| `secret` | `{}` | Key-value list of environment variables to be shared with Postfix / OpenDKIM as secrets |
| `mountSecret.enabled` | `false` | Create a folder with contents of the secret in the pod's container |
| `mountSecret.path` | `/var/lib/secret` | Where to mount secret data |
| `mountSecret.data` | `{}` | Key-value list of files to be mount into the container |
| `persistence.enabled` | `true` | Persist Postfix's queue on disk |
| `persistence.accessModes` | `[ 'ReadWriteOnce' ]` | Access mode |
| `persistence.existingClaim` | `""` | Provide an existing `PersistentVolumeClaim`, the value is evaluated as a template. |
Expand Down
17 changes: 17 additions & 0 deletions helm/mail/templates/secret-mount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.mountSecret.enabled -}}
{{- $chart := "mail" -}}
{{- $fullName := include (print $chart ".fullname") . -}}
{{- $labels := include (print $chart ".labels") . -}}
{{- with .Values.mountSecret.data }}
apiVersion: v1
kind: Secret
metadata:
name: {{ $fullName }}-mount
labels:
{{- $labels | nindent 4 }}
data:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | b64enc | quote }}
{{- end }}
{{ end }}
{{- end -}}
12 changes: 11 additions & 1 deletion helm/mail/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ spec:
readOnly: true
subPath: _enable_tls.sh
{{- end }}
{{- if .Values.mountSecret.enabled }}
- name: mount-secret
mountPath: {{ .Values.mountSecret.path }}
readOnly: true
{{- end }}
{{- if .Values.extraVolumeMounts }}{{- toYaml .Values.extraVolumeMounts | nindent 12 }}{{ end }}
resources: {{ toYaml .Values.resources | nindent 12 }}
{{- if .Values.extraContainers }}
Expand Down Expand Up @@ -135,6 +140,11 @@ spec:
- name: {{ $fullName }}
emptyDir: {}
{{- end }}
{{- if .Values.mountSecret.enabled }}
- name: mount-secret
secret:
secretName: {{ $fullName }}-mount
{{- end }}
{{- if .Values.extraVolumes }}{{- toYaml .Values.extraVolumes | nindent 8 }}{{ end }}
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
volumeClaimTemplates:
Expand All @@ -145,7 +155,7 @@ spec:
accessModes: {{- toYaml .Values.persistence.accessModes | nindent 10 }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- end }}{{- if .Values.persistence.storageClass }}
{{- else if .Values.persistence.storageClass }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
resources:
Expand Down
12 changes: 12 additions & 0 deletions helm/mail/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ certs:
# hello: world
secret: {}

# Define a secret which should be deployed together with the
# chart amd mounted into a specific directory in the pod.
mountSecret:
enabled: false
path: /var/lib/secret
data: {}
# e.g.
# dkim-private: |
# -----BEGIN RSA PRIVATE KEY-----
# < redacted >
# -----END RSA PRIVATE KEY-----

config:
general: {}
# e.g.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions helm/test_10_mount_secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mountSecret:
enabled: true
path: /test
data:
dkim-private: |
-----BEGIN RSA PRIVATE KEY-----
< redacted >
-----END RSA PRIVATE KEY-----

0 comments on commit fab1b33

Please sign in to comment.