apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: image-pruner
  namespace: openshift-sre-pruning
spec:
  failedJobsHistoryLimit: 5
  successfulJobsHistoryLimit: 3
  concurrencyPolicy: Replace
  schedule: "30 */1 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: sre-pruner-sa
          restartPolicy: Never
          containers:
          - name: image-pruner
            image: image-registry.openshift-image-registry.svc:5000/openshift/cli:latest
            imagePullPolicy: Always
            args:
            - /bin/bash
            - -c
            - >-
              oc adm prune images
              --token=$$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
              --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
              --keep-younger-than=24h
              --keep-tag-revisions=5
              --ignore-invalid-refs=true
              --confirm
