apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: nfs-backup
spec:
  # At 01:00 in UTC
  schedule: "0 1 * * *"
  # Setting a limit to 0 corresponds to keeping none of the corresponding kind of jobs after they finish.
  successfulJobsHistoryLimit: 0
  failedJobsHistoryLimit: 7
  jobTemplate:
    spec:
      template:
        metadata:
          name: nfs-backup
        spec:
          restartPolicy: OnFailure
          serviceAccount: nfs-backup
          nodeSelector:
            # because of hostPath PVs
            base: worker
          containers:
          - name: nfs-backup
            image: gesiscss/nfs-backup-orc:cc6df1b
            env:
              - name: SSHPASS
                valueFrom:
                  secretKeyRef:
                    name: worker-node-pass
                    key: password
              - name: PV_FOLDER
                value: "/export"
              - name: BACKUP_FOLDER
                value: "/backup"
              - name: MAX_WORKERS
                value: "5"
            volumeMounts:
              - name: export-volume
                mountPath: /export
              - name: backup-volume
                mountPath: /backup
          volumes:
            - name: export-volume
              hostPath:
                path: /xfs/nfs
            - name: backup-volume
              hostPath:
                path: /xfs/backup/nfs
