{{ if .Values.opportunity_cost.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
  name: opportunity-cost
spec:
  schedule: "{{ .Values.opportunity_cost.schedule }}"
  jobTemplate:
    spec:
      ttlSecondsAfterFinished: 12000
      backoffLimit: 1
      template:
        spec:
          imagePullSecrets:
          - name: regcred
          containers:
          - name: model
            image: goalprofit/opportunity_cost:1.0
            imagePullPolicy: Always
            env:
              - name: ADMIN_LOGIN
                valueFrom:
                  secretKeyRef:
                    name: secret-admin
                    key: username
                    optional: false
              - name: ADMIN_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: secret-admin
                    key: password
                    optional: false
              - name: SERVICE_LOGIN
                valueFrom:
                  secretKeyRef:
                    name: secret-service
                    key: username
                    optional: false
              - name: SERVICE_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: secret-service
                    key: password
                    optional: false
            command: ["/bin/bash", "-c"]
            args: ["python /app/main.py --url {{.Values.protocol}}{{ .Values.domain }} --strategy {{ .Values.opportunity_cost.strategy }} --instant-lag {{ .Values.opportunity_cost.instant_lag }} --delayed-lag {{ .Values.opportunity_cost.delayed_lag }} --date {{ .Values.opportunity_cost.date }}"]
          restartPolicy: Never
          {{ include "app.affinity" . | nindent 10}}
{{ end }}