{{ if .Values.mail.enabled }}
apiVersion: apps/v1
kind: Deployment 
metadata:
  name: mail
spec:
  selector:
    matchLabels:
      app: mail
  template:
    metadata:
      labels:
        app: mail
    spec:
      containers:
        - name: mail
          image: goalprofit/gp-mail:latest
          imagePullPolicy: Always
          command:
            - python3
            - main.py
          volumeMounts:
            - mountPath: /etc/ssmtp/ssmtp.conf
              name: ssmtp-config
      imagePullSecrets:
        - name: regcred          
      restartPolicy: Always
      volumes:
        - name: ssmtp-config
          hostPath:
            path: {{.Values.mail.ssmtp_config_path}}
            type: File
      {{ include "app.affinity" . | nindent 6}}
---
apiVersion: v1
kind: Service
metadata:
  name: mail
spec:
  type: ClusterIP
  selector:
    app: mail
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 5050
{{ end }}
