Scheduling an OpenShift “job”

I have a backup process that involves an Openshift “job”.
We fire off this job by

  • oc delete the previous job object
  • Edit the following yaml with the backup location which is either backupa or backupb mount. this alternates each time we do a backup so we always have the last 2 backups.
apiVersion: batch/v1
kind: Job
metadata:
  name: backup-job
spec:
  template:
    spec:
      containers:
      - name: backup-job
        image: example-registry.svc:5000/someproject/some-image:latest
        args:
        - /bin/sh
        - -c
        - DIR=/path/to/backupb; cd ${DIR}; /do/backup
        volumeMounts:
          - mountPath: /path/to/backupa
            name: example-backup-dira
          - mountPath: /path/to/backupb
            name: example-backup-dirb
      volumes:
      - name: connector-data
        persistentVolumeClaim:
          claimName: shared-connector-data
      - name: example-backup-dira
        persistentVolumeClaim:
          claimName: backupa
      - name: example-backup-dirb
        persistentVolumeClaim:
          claimName: backupb
      restartPolicy: Never
  backoffLimit: 1
  • oc create the yaml which iniates the backup.

I would like to create a weekly job for this that runs on a schedule.

What is the Openshift/Kubernetes way of scheduling such a thing?

Google gets me here https://docs.openshift.com/container-platform/3.3/dev_guide/scheduled_jobs.html

But I’m a little unclear how to use this? Do I create a template for my backup job and then create a scheduled job that takes my backup template, substitutes the backup mount variable, and runs based on a Cron expression?

I’m just looking for a little guidance how the Openshift experts out there accomplish this so I’m not shooting in the dark.

Go to Source
Author: Nicholas DiPiazza