{{ if .Values.work.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: work
spec:
  replicas: 1
  selector:
    matchLabels:
      app: work
  template:
    metadata:
      name: work
      labels:
        app: work
    spec:
      containers:
      - name: work
        image: docker.io/goalprofit/env:1.1
        imagePullPolicy: Always
        args:
          - bash
          - -c
          - |
            pip3 install requests
            while true
            do
            python3 ./work.py
            sleep 1m
            done        
        workingDir: /data
        volumeMounts:
        - mountPath: /data
          name: data
        env:
        - name: TZ
          value: {{ .Values.timeZone }}
        - name: SERVICE_LOGIN
          valueFrom:
            secretKeyRef:
              name: secret-admin
              key: username
              optional: false
        - name: SERVICE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: secret-admin
              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: data
        hostPath:
          path: /data/{{.Values.customer}}/in/int/retail
          type: Directory
      {{ include "app.affinity" . | nindent 6}}
{{ end }}