apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: cv-data-extract
  namespace: cv
  labels:
    app: cv-data-extract
spec:
  schedule: "0 * * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        metadata:
          annotations:
            # Lets disable istio injection for this job because 
            # the sidecar will never terminate and cause the cronjob
            # to never succeed
            sidecar.istio.io/inject: "false"
        spec:
          containers:
          - name: cv-data-extract
            image: danpilch/cv-data:1 
            env:
            - name: MYSQL_HOST
              value: coronavirus-db-service
            - name: MYSQL_USER
              valueFrom:
                secretKeyRef:
                  name: mysql-config
                  key: MYSQL_USER_USERNAME
            - name: MYSQL_PASS
              valueFrom:
                secretKeyRef:
                  name: mysql-config
                  key: MYSQL_USER_PASSWORD
          restartPolicy: OnFailure
