apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: cleanup
spec:
  schedule: "0 6 * * *"
  concurrencyPolicy: Replace
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: shiftzilla
            image: docker-registry.default.svc:5000/shiftzilla/shiftzilla
            args:
              - /bin/bash
              - -c
              - "/usr/bin/find /shiftzilla/storage/archive/* -type d | sort | head -n -3 | xargs rm -rf; sqlite3 /shiftzilla/storage/shiftzilla.sqlite -echo \"DELETE FROM ALL_BUGS WHERE Snapshot < date('now','localtime','-180 days');VACUUM;\""
            volumeMounts:
              - name: shiftzilla-storage
                mountPath: /shiftzilla/storage
          restartPolicy: OnFailure
          volumes:
            - name: shiftzilla-storage
              persistentVolumeClaim:
                claimName: shiftzilla-state
