apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: exportjob
spec:
  schedule: "*/2 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: export
            image: jbergknoff/postgresql-client
            command: ["/bin/sh"]
            args: ["-c", "psql -c \"\\copy (Select * From todo) To /exports/$(date +%s).csv With CSV\""]
            envFrom:
              - secretRef:
                  name: psql
            volumeMounts:
            - name: exportvolume
              mountPath: "/exports"
              readOnly: false
            resources:  
              limits:  
                cpu: 10m
                memory: 32Mi
              requests: 
                cpu: 10m
                memory: 32Mi
          volumes:
            - name: exportvolume
              azureFile:
                secretName: images-secret
                shareName: exports
                readOnly: false
          restartPolicy: OnFailure