diff --git a/mailu/README.md b/mailu/README.md index 3246dc2f..2ed95029 100644 --- a/mailu/README.md +++ b/mailu/README.md @@ -437,11 +437,13 @@ Check that the deployed pods are all running. ### Postfix parameters | Name | Description | Value | -| ----------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------- | +|-------------------------------------------------|---------------------------------------------------------------------------------------|---------------------| | `postfix.logLevel` | Override default log level | `""` | | `postfix.image.repository` | Pod image repository | `mailu/postfix` | | `postfix.image.tag` | Pod image tag (defaults to mailuVersion if set, otherwise Chart.AppVersion) | `""` | | `postfix.image.pullPolicy` | Pod image pull policy | `IfNotPresent` | +| `postfix.kind` | Kind of resource to create for postfix (`Deployment` or `StatefulSet`) | `Deployment` | +| `postfix.replicaCount` | Number of front replicas to deploy (only for `StatefulSet` kind) | `StatefulSet` | | `postfix.persistence.size` | Pod pvc size | `20Gi` | | `postfix.persistence.storageClass` | Pod pvc storage class | `""` | | `postfix.persistence.accessModes` | Pod pvc access modes | `["ReadWriteOnce"]` | diff --git a/mailu/templates/postfix/deployment.yaml b/mailu/templates/postfix/deployment.yaml index 4a933f55..d305531a 100644 --- a/mailu/templates/postfix/deployment.yaml +++ b/mailu/templates/postfix/deployment.yaml @@ -1,6 +1,6 @@ --- apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }} -kind: Deployment +kind: {{ .Values.postfix.kind }} metadata: name: {{ printf "%s-postfix" (include "mailu.fullname" .) }} namespace: {{ include "common.names.namespace" . | quote }} @@ -13,7 +13,12 @@ metadata: annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} spec: + {{- if eq .Values.postfix.kind "StatefulSet" }} + replicas: {{ .Values.postfix.replicaCount }} + podManagementPolicy: "Parallel" + {{- else }} replicas: 1 + {{- end }} {{- if .Values.postfix.updateStrategy }} strategy: {{- toYaml .Values.postfix.updateStrategy | nindent 4 }} {{- end }} @@ -140,9 +145,11 @@ spec: - '! /usr/libexec/postfix/master -t' {{- end }} volumes: + {{- if not (eq .Values.postfix.kind "StatefulSet") }} - name: data persistentVolumeClaim: claimName: {{ include "mailu.postfix.claimName" . }} + {{- end }} {{- if .Values.postfix.overrides }} - name: overrides configMap: @@ -151,3 +158,40 @@ spec: {{- if .Values.postfix.extraVolumes }} {{- include "common.tplvalues.render" (dict "value" .Values.postfix.extraVolumes "context" $) | nindent 8 }} {{- end }} +{{- if eq .Values.postfix.kind "StatefulSet" }} + volumeClaimTemplates: + - metadata: + name: data + labels: {{- include "common.labels.standard" . | nindent 10 }} + app.kubernetes.io/component: postfix + {{- if .Values.postfix.persistence.labels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.postfix.persistence.labels "context" $ ) | nindent 10 }} + {{- end }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 10 }} + {{- end }} + {{- if or .Values.postfix.persistence.annotations .Values.commonAnnotations }} + annotations: + {{- if .Values.postfix.persistence.annotations }} + {{- include "common.tplvalues.render" ( dict "value" .Values.postfix.persistence.annotations "context" $ ) | nindent 10 }} + {{- end }} + {{- if .Values.commonAnnotations }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 10 }} + {{- end }} + {{- end }} + spec: + accessModes: + {{- range .Values.postfix.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.postfix.persistence.size | quote }} + {{- if .Values.postfix.persistence.selector }} + selector: {{- include "common.tplvalues.render" (dict "value" .Values.postfix.persistence.selector "context" $) | nindent 10 }} + {{- end }} + {{- if .Values.postfix.persistence.dataSource }} + dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.postfix.persistence.dataSource "context" $) | nindent 10 }} + {{- end }} + {{- include "common.storage.class" (dict "persistence" .Values.postfix.persistence "global" .Values.global) | nindent 8 }} +{{- end }} diff --git a/mailu/templates/postfix/pvc.yaml b/mailu/templates/postfix/pvc.yaml index 1d02e0a6..4766f461 100644 --- a/mailu/templates/postfix/pvc.yaml +++ b/mailu/templates/postfix/pvc.yaml @@ -1,5 +1,5 @@ --- -{{- if not .Values.persistence.single_pvc }} +{{- if and (not .Values.persistence.single_pvc) (eq .Values.postfix.kind "Deployment") }} kind: PersistentVolumeClaim apiVersion: v1 metadata: diff --git a/mailu/values.yaml b/mailu/values.yaml index 03ea51a0..7bbc6c55 100644 --- a/mailu/values.yaml +++ b/mailu/values.yaml @@ -1100,6 +1100,12 @@ postfix: tag: "" pullPolicy: IfNotPresent + ## @param postfix.kind Kind of resource to create for postfix (`Deployment` or `StatefulSet`) + kind: Deployment + + ## @param postfix.replicaCount Number of front replicas to deploy (only for `StatefulSet` kind) + replicaCount: 1 + ## Pod persistence (if not using single_pvc) ## @param postfix.persistence.size Pod pvc size ## @param postfix.persistence.storageClass Pod pvc storage class