2025-05-11 00:34:55 +03:00

165 lines
7.6 KiB
YAML

---
{{- if .Values.dovecot.enabled }}
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ printf "%s-dovecot" (include "mailu.fullname" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: dovecot
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
replicas: 1
{{- if .Values.dovecot.updateStrategy }}
strategy: {{- toYaml .Values.dovecot.updateStrategy | nindent 4 }}
{{- end }}
revisionHistoryLimit: {{ .Values.dovecot.revisionHistoryLimit }}
selector:
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
app.kubernetes.io/component: dovecot
template:
metadata:
labels: {{- include "common.labels.standard" . | nindent 8 }}
app.kubernetes.io/component: dovecot
{{- if .Values.dovecot.podLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.dovecot.podLabels "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.dovecot.podAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.dovecot.podAnnotations "context" $) | nindent 8 }}
{{- end }}
spec:
{{- include "common.images.pullSecrets" (dict "images" (list .Values.dovecot.image) "global" .Values.global) | nindent 6 }}
{{- if .Values.dovecot.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.dovecot.hostAliases "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.dovecot.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.dovecot.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.dovecot.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.dovecot.affinity "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.dovecot.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.dovecot.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.dovecot.priorityClassName }}
priorityClassName: {{ .Values.dovecot.priorityClassName | quote }}
{{- end }}
{{- if .Values.dovecot.schedulerName }}
schedulerName: {{ .Values.dovecot.schedulerName | quote }}
{{- end }}
{{- if .Values.dovecot.topologySpreadConstraints }}
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.dovecot.topologySpreadConstraints "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.dovecot.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.dovecot.terminationGracePeriodSeconds }}
{{- end }}
{{- if .Values.dovecot.initContainers }}
initContainers: {{- include "common.tplvalues.render" (dict "value" .Values.dovecot.initContainers "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.dovecot.podSecurityContext.enabled }}
securityContext: {{- omit .Values.dovecot.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
containers:
- name: dovecot
image: {{ .Values.imageRegistry }}/{{ .Values.dovecot.image.repository }}:{{ default (include "mailu.version" .) .Values.dovecot.image.tag }}
imagePullPolicy: {{ .Values.dovecot.image.pullPolicy }}
{{- if .Values.dovecot.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.dovecot.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
volumeMounts:
- name: data
subPath: dovecotdata
mountPath: /data
- name: data
subPath: dovecotmail
mountPath: /mail
{{- if .Values.dovecot.overrides }}
- name: overrides
mountPath: /overrides
{{- end }}
{{- if .Values.dovecot.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.dovecot.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
env:
- name: LOG_LEVEL
value: {{ default .Values.logLevel .Values.dovecot.logLevel }}
{{- tpl (include "mailu.envvars.secrets" .) $ | nindent 12 }}
{{- if .Values.dovecot.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.dovecot.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ printf "%s-envvars" (include "mailu.fullname" .) }}
{{- if .Values.dovecot.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.dovecot.extraEnvVarsCM "context" $) }}
{{- end }}
{{- if .Values.dovecot.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.dovecot.extraEnvVarsSecret "context" $) }}
{{- end }}
ports:
- name: auth
containerPort: 2102
protocol: TCP
- name: lmtp
containerPort: 2525
protocol: TCP
- name: imap
containerPort: 143
protocol: TCP
- name: pop3
containerPort: 110
protocol: TCP
- name: sieve
containerPort: 4190
protocol: TCP
{{- if .Values.dovecot.resources }}
resources: {{- toYaml .Values.dovecot.resources | nindent 12 }}
{{- end }}
{{- if .Values.dovecot.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.dovecot.startupProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- sh
- -c
- 'kill -0 `cat /run/dovecot/master.pid`'
{{- end }}
{{- if .Values.dovecot.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.dovecot.livenessProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- sh
- -c
- 'kill -0 `cat /run/dovecot/master.pid`'
{{- end }}
{{- if .Values.dovecot.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.dovecot.readinessProbe "enabled") "context" $) | nindent 12 }}
exec:
command:
- sh
- -c
- 'kill -0 `cat /run/dovecot/master.pid`'
{{- end }}
{{- if .Values.dovecot.extraContainers }}
{{- toYaml .Values.dovecot.extraContainers | nindent 8 }}
{{- end }}
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ include "mailu.dovecot.claimName" . }}
{{- if .Values.dovecot.overrides }}
- name: overrides
configMap:
name: {{ printf "%s-dovecot-override" (include "mailu.fullname" .) }}
{{- end }}
{{- if .Values.dovecot.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.dovecot.extraVolumes "context" $) | nindent 8 }}
{{- end }}
{{- end }}