From 23cf1419895ab4a98ad522a3cc4fc5d8f423964d Mon Sep 17 00:00:00 2001 From: Pavel Sheldiaev
Date: Fri, 20 Sep 2024 08:49:02 +0300 Subject: [PATCH] persistence --- chart/templates/_config.yaml | 4 ++++ chart/templates/_persistence.yaml | 33 +++++++++++++++++++++++++++++++ chart/templates/deployment.yaml | 1 + chart/values.yaml | 8 ++++++++ 4 files changed, 46 insertions(+) create mode 100644 chart/templates/_persistence.yaml diff --git a/chart/templates/_config.yaml b/chart/templates/_config.yaml index a50714b..5f3a9c4 100644 --- a/chart/templates/_config.yaml +++ b/chart/templates/_config.yaml @@ -42,7 +42,11 @@ type: {{ ternary "kubernetes.io/tls" "Opaque" (eq "tls" $config.type) }} */}} data: {{- range $fileName, $fileData := $config.data }} +{{- if (kindIs "string" $fileData) }} {{ $fileName }}: {{ $fileData | b64enc | quote }} +{{- else }} + {{ $fileName }}: {{ $fileData | toYaml | b64enc | quote }} +{{- end }} {{- end }} {{- else }} {{- with $config.data }} diff --git a/chart/templates/_persistence.yaml b/chart/templates/_persistence.yaml new file mode 100644 index 0000000..37d86f9 --- /dev/null +++ b/chart/templates/_persistence.yaml @@ -0,0 +1,33 @@ +{{- define "chart.persistence" }} +{{- if .Values.persistence.enabled }} + +{{- if not .Values.persistence.existingClaim }} +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "chart.fullname" . }}-spool + labels: + {{- include "chart.labels" . | nindent 4 }} +spec: + storageClassName: {{ .Values.persistence.storageClass }} + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- end }} + +{{- $_ := set $.Values "volumeMounts" (append $.Values.volumeMounts (dict + "name" "spool" + "mountPath" "/var/spool/postfix" +)) }} +{{- $_ := set $.Values "volumes" (append $.Values.volumes (dict + "name" "spool" + "persistentVolumeClaim" (dict + "claimName" (.Values.persistence.existingClaim | default (print (include "chart.fullname" .) "-spool")) + ) +)) }} + +{{- end }} +{{- end }} diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml index 131680b..2e6a52d 100644 --- a/chart/templates/deployment.yaml +++ b/chart/templates/deployment.yaml @@ -1,4 +1,5 @@ {{- template "chart.config" . }} +{{- template "chart.persistence" . }} --- apiVersion: apps/v1 kind: Deployment diff --git a/chart/values.yaml b/chart/values.yaml index e31b0a5..91ccca7 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -31,6 +31,14 @@ config: env: type: env +# /var/spool/postfix +persistence: + enabled: false + existingClaim: "" + storageClass: "" + accessMode: ReadWriteOnce + size: 1Gi + replicaCount: 1 image: