apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: backup-database
spec:
  schedule: "0 0,6,9,12,15,18 * * *"
  jobTemplate:
    spec:
      template:
        metadata:
          name: backup-databases
        spec:
          volumes:
            - name: backup-dir
              cephfs:
                monitors:
                - 10.42.1.1:6789
                - 10.42.1.2:6789
                - 10.42.1.3:6789
                user: kube
                path: /backups
                secretRef:
                  name: ktel-ceph-user-secret
                readOnly: false
          containers:
          - name: backuper
            image: xetys/open-psql-backup:latest
            imagePullPolicy: Always
            command: ["/back-up.sh"]
            env:
              - name: BACKUP_DIR
                value: /backups
              - name: NAMESPACE
                value: kloud
            volumeMounts:
            - name: backup-dir
              mountPath: /backups
          restartPolicy: Never
          serviceAccount: backuper
      backoffLimit: 4
