apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: {{ include "inbucket.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    helm.sh/chart: {{ include "inbucket.chart" . }}
  name: {{ include "inbucket.fullname" . }}
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "inbucket.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
    {{- if .Values.podAnnotations }}
      annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
    {{- end }}
      labels:
        app.kubernetes.io/name: {{ include "inbucket.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
        app.kubernetes.io/managed-by: {{ .Release.Service }}
        helm.sh/chart: {{ include "inbucket.chart" . }}
    spec:
      containers:
        - name: {{ include "inbucket.name" . }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: "{{ .Values.image.pullPolicy }}"
          envFrom:
          - configMapRef:
              name: {{ include "inbucket.name" . }}-configmap
          ports:
            - name: http
              containerPort: 9000
              protocol: TCP
            - name: smtp
              containerPort: 2500
              protocol: TCP
            - name: pop3
              containerPort: 1100
              protocol: TCP
          livenessProbe:
            tcpSocket:
              port: smtp
            initialDelaySeconds: 10
            timeoutSeconds: 5
          readinessProbe:
            tcpSocket:
              port: smtp
            initialDelaySeconds: 10
            timeoutSeconds: 5
          resources:
{{ toYaml .Values.resources | indent 12 }}
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}
