Skip to content

Commit

Permalink
persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
theshell76 committed Sep 20, 2024
1 parent 66a20da commit 23cf141
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chart/templates/_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
33 changes: 33 additions & 0 deletions chart/templates/_persistence.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- template "chart.config" . }}
{{- template "chart.persistence" . }}
---
apiVersion: apps/v1
kind: Deployment
Expand Down
8 changes: 8 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ config:
env:
type: env

# /var/spool/postfix
persistence:
enabled: false
existingClaim: ""
storageClass: ""
accessMode: ReadWriteOnce
size: 1Gi

replicaCount: 1

image:
Expand Down

0 comments on commit 23cf141

Please sign in to comment.