apiVersion: batch/v1
kind: Job
metadata:
  name: mysql-backup
spec:
  completions: 1
  parallelism: 1
  template:
    spec:
      containers:
      - name: backup-mysql
        image: k8spracticalguide/mysql:5.7.22
        envFrom:
        - configMapRef:
            name: common-env
        - secretRef:
            name: common-env
        command: ["bash",  "/mnt/backup-script/backup-db.sh"]
        volumeMounts:
        - name: backup-script
          mountPath: /mnt/backup-script
        - name: backup
          mountPath: /mnt/backup
      restartPolicy: Never
      volumes:
       - name: backup-script
         configMap:
           name: mysql-backup
       - name: backup
         persistentVolumeClaim:
           claimName: backup-mysql
  backoffLimit: 3
