{{ if .Values.cron.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cron
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cron
  template:
    metadata:
      name: cron
      labels:
        app: cron
    spec:
      containers:
      - name: cron
        image: docker.io/goalprofit/env:1.1
        imagePullPolicy: Always
        args:
          - python3
          - "-u"
          - cron.py
        workingDir: /work
        volumeMounts:
        - mountPath: /work
          name: work
          subPath: in/int/retail
        env:
        - name: TZ
          value: {{ .Values.timeZone }}
        - name: SERVICE_LOGIN
          valueFrom:
            secretKeyRef:
              name: secret-service
              key: username
              optional: false
        - name: SERVICE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: secret-service
              key: password
              optional: false
{{ if .Values.local_user_id }}
        - name: LOCAL_USER_ID
          value: "{{.Values.local_user_id}}"
{{ end }}
{{ if .Values.local_user_name }}
        - name: LOCAL_USER_NAME
          value: "{{.Values.local_user_name}}"
{{ end }}

      imagePullSecrets:
      - name: regcred
      volumes:
      - name: work
        {{ include "app.customer_volume" . | nindent 8}}
      {{ include "app.affinity" . | nindent 6}}

{{ end }}