apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: prune-builds
  namespace: cluster-operations
spec:
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  schedule: "00 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          nodeSelector:
            node-role.kubernetes.io/worker: ""
          containers:
          - name: prune-builds
            image: registry.redhat.io/openshift4/ose-cli:v4.7
            command:
            - /bin/bash
            - -c
            - |
              #/bin/bash
              oc adm prune builds --orphans --keep-complete=3 --keep-failed=1 --keep-younger-than=60m --confirm
            imagePullPolicy: Always
            env:
            - name: HOME
              value: "/tmp"
          restartPolicy: OnFailure
          serviceAccountName: cron-prune-runner-sa
          imagePullSecrets:
          - name: xyz-user-pull-secret
