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:
            - mountPath: /mnt/backup-script
              name: backup-script
            - mountPath: /mnt/backup
              name: backup
      restartPolicy: Never
      volumes:
        - name: backup-script
          configMap:
            name: mysql-backup
        - name: backup
          persistentVolumeClaim:
            claimName: backup-mysql
  backoffLimit: 3