apiVersion: batch/v1
kind: CronJob
metadata:
  name: {{ .Values.cronJob.name }}
spec:
  schedule: {{ .Values.backup.controlPlane.schedule | default "30 9 * * MON-FRI" | squote}}
  jobTemplate:
    spec:
     template:
      spec:
        containers:
        - name: {{ .Values.cronJob.name }}
          image: {{ include "velero.job.image" . }}
          imagePullPolicy: IfNotPresent
          command:
            - /bin/sh
            - -c
            - /tmp/backup/{{ .Values.cronJob.backupScriptName }}
          volumeMounts:
            - mountPath: /tmp/backup/{{ .Values.cronJob.backupScriptName }}
              subPath: {{ .Values.cronJob.backupScriptName }}
              name: backup
        volumes:
        - name: backup
          configMap:
            name: {{ .Values.cronJob.configMapName }}
            defaultMode: 0777
        restartPolicy: OnFailure
        serviceAccountName: {{ .Values.cronJob.name }}
        serviceAccount: {{ .Values.cronJob.name }}