---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  labels:
    app.kubernetes.io/name: mysql-bkp-cronjob
    app.kubernetes.io/instance: meertime
  name: mysql-bkp-cronjob
  namespace: meertime
spec:
  schedule: 30 1 * * *
  concurrencyPolicy: Forbid
  failedJobsHistoryLimit: 7
  jobTemplate:
    metadata:
      labels:
        app: mysql-bkp
        tier: database
        cronjob-name: mysql-bkp-job
    spec:
      backoffLimit: 1
      template:
        spec:
          containers:
            - command:
                - /bin/sh
                - /scripts/backup.sh
              env:
                - name: MYSQL_ROOT_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: db-root-credentials
                      key: password
              envFrom:
                - configMapRef:
                    name: mysql-bkp-configmap
                - secretRef:
                    name: db-config
              image: "nexus.gwdc.org.au/docker/mysqldump:0.2"
              imagePullPolicy: IfNotPresent
              name: mysql-backup
              resources: {}
              volumeMounts:
                - mountPath: /backup
                  name: backups
                - mountPath: /scripts
                  name: mysql-backup-script
          imagePullSecrets:
            - name: regcred
          restartPolicy: Never
          volumes:
            - name: backups
              persistentVolumeClaim:
                claimName: mysql-bkp-pv-claim
            - configMap:
                name: mysql-bkp-script-configmap
              name: mysql-backup-script
  successfulJobsHistoryLimit: 7
