{{ if .Values.export_mail.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: export-mail
spec:
  replicas: 1
  selector:
    matchLabels:
      app: export-mail
  template:
    metadata:
      name: export-mail
      labels:
        app: export-mail
    spec:
      terminationGracePeriodSeconds: 1
      containers:
      - name: export-mail
        image: docker.io/goalprofit/export-mail:{{.Values.export_mail.version}}
        imagePullPolicy: Always
        env:
          - name: SERVICE_URL
            value: http://server:8080
          - name: SITE_URL
            value: {{ .Values.export_mail.site_url }}
          - name: MAIL_SERVER_URL
            value: http://mail
          - name: SERVICE_LOGIN
            valueFrom:
              secretKeyRef:
                name: secret-service
                key: username
                optional: false
          - name: SERVICE_PASSWORD
            valueFrom:
              secretKeyRef:
                name: secret-service
                key: password
                optional: false
      imagePullSecrets:
      - name: regcred
      {{ include "app.affinity" . | nindent 6}}
---
apiVersion: v1
kind: Service
metadata:
  name: export-mail
spec:
  type: ClusterIP
  selector:
    app: export-mail
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
{{ end }}