Skip to content

Commit 38b704d

Browse files
committed
Add StatefulSet deployment for postfix
1 parent 2eec0ca commit 38b704d

4 files changed

Lines changed: 54 additions & 2 deletions

File tree

mailu/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,13 @@ Check that the deployed pods are all running.
437437
### Postfix parameters
438438

439439
| Name | Description | Value |
440-
| ----------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------- |
440+
|-------------------------------------------------|---------------------------------------------------------------------------------------|---------------------|
441441
| `postfix.logLevel` | Override default log level | `""` |
442442
| `postfix.image.repository` | Pod image repository | `mailu/postfix` |
443443
| `postfix.image.tag` | Pod image tag (defaults to mailuVersion if set, otherwise Chart.AppVersion) | `""` |
444444
| `postfix.image.pullPolicy` | Pod image pull policy | `IfNotPresent` |
445+
| `postfix.kind` | Kind of resource to create for postfix (`Deployment` or `StatefulSet`) | `Deployment` |
446+
| `postfix.replicaCount` | Number of front replicas to deploy (only for `StatefulSet` kind) | `StatefulSet` |
445447
| `postfix.persistence.size` | Pod pvc size | `20Gi` |
446448
| `postfix.persistence.storageClass` | Pod pvc storage class | `""` |
447449
| `postfix.persistence.accessModes` | Pod pvc access modes | `["ReadWriteOnce"]` |

mailu/templates/postfix/deployment.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ metadata:
1313
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
1414
{{- end }}
1515
spec:
16+
{{- if eq .Values.postfix.kind "StatefulSet" }}
17+
replicas: {{ .Values.postfix.replicaCount }}
18+
podManagementPolicy: "Parallel"
19+
{{- else }}
1620
replicas: 1
21+
{{- end }}
1722
{{- if .Values.postfix.updateStrategy }}
1823
strategy: {{- toYaml .Values.postfix.updateStrategy | nindent 4 }}
1924
{{- end }}
@@ -140,9 +145,11 @@ spec:
140145
- '! /usr/libexec/postfix/master -t'
141146
{{- end }}
142147
volumes:
148+
{{- if not eq .Values.postfix.kind "StatefulSet" }}
143149
- name: data
144150
persistentVolumeClaim:
145151
claimName: {{ include "mailu.postfix.claimName" . }}
152+
{{- end }}
146153
{{- if .Values.postfix.overrides }}
147154
- name: overrides
148155
configMap:
@@ -151,3 +158,40 @@ spec:
151158
{{- if .Values.postfix.extraVolumes }}
152159
{{- include "common.tplvalues.render" (dict "value" .Values.postfix.extraVolumes "context" $) | nindent 8 }}
153160
{{- end }}
161+
{{- if eq .Values.postfix.kind "StatefulSet" }}
162+
volumeClaimTemplates:
163+
- metadata:
164+
name: data
165+
labels: {{- include "common.labels.standard" . | nindent 10 }}
166+
app.kubernetes.io/component: postfix
167+
{{- if .Values.postfix.persistence.labels }}
168+
{{- include "common.tplvalues.render" ( dict "value" .Values.postfix.persistence.labels "context" $ ) | nindent 10 }}
169+
{{- end }}
170+
{{- if .Values.commonLabels }}
171+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 10 }}
172+
{{- end }}
173+
{{- if or .Values.postfix.persistence.annotations .Values.commonAnnotations }}
174+
annotations:
175+
{{- if .Values.postfix.persistence.annotations }}
176+
{{- include "common.tplvalues.render" ( dict "value" .Values.postfix.persistence.annotations "context" $ ) | nindent 10 }}
177+
{{- end }}
178+
{{- if .Values.commonAnnotations }}
179+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 10 }}
180+
{{- end }}
181+
{{- end }}
182+
spec:
183+
accessModes:
184+
{{- range .Values.postfix.persistence.accessModes }}
185+
- {{ . | quote }}
186+
{{- end }}
187+
resources:
188+
requests:
189+
storage: {{ .Values.postfix.persistence.size | quote }}
190+
{{- if .Values.postfix.persistence.selector }}
191+
selector: {{- include "common.tplvalues.render" (dict "value" .Values.postfix.persistence.selector "context" $) | nindent 10 }}
192+
{{- end }}
193+
{{- if .Values.postfix.persistence.dataSource }}
194+
dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.postfix.persistence.dataSource "context" $) | nindent 10 }}
195+
{{- end }}
196+
{{- include "common.storage.class" (dict "persistence" .Values.postfix.persistence "global" .Values.global) | nindent 8 }}
197+
{{- end }}

mailu/templates/postfix/pvc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
{{- if not .Values.persistence.single_pvc }}
2+
{{- if not .Values.persistence.single_pvc and eq .Values.postfix.kind "Deployment" }}
33
kind: PersistentVolumeClaim
44
apiVersion: v1
55
metadata:

mailu/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,12 @@ postfix:
11001100
tag: ""
11011101
pullPolicy: IfNotPresent
11021102

1103+
## @param postfix.kind Kind of resource to create for postfix (`Deployment` or `StatefulSet`)
1104+
kind: Deployment
1105+
1106+
## @param postfix.replicaCount Number of front replicas to deploy (only for `StatefulSet` kind)
1107+
replicaCount: 1
1108+
11031109
## Pod persistence (if not using single_pvc)
11041110
## @param postfix.persistence.size Pod pvc size
11051111
## @param postfix.persistence.storageClass Pod pvc storage class

0 commit comments

Comments
 (0)