apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: offender-manager-integration-test-cleanup
spec:
  schedule: "0 0 * * *"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: integration-test-cleanup
            image: 754256621582.dkr.ecr.eu-west-2.amazonaws.com/offender-management/offender-management-allocation-manager:latest
            imagePullPolicy: Always
            command: ['sh', '-c', "bundle exec rake integration_tests:clean_up"]
            envFrom:
              - configMapRef:
                  name: shared-environment
              - secretRef:
                  name: allocation-manager-secrets
            env:
              - name: PROMETHEUS_METRICS
                value: "off"
              - name: POSTGRES_HOST
                valueFrom:
                  secretKeyRef:
                    name: allocation-rds-instance-output
                    key: rds_instance_address
              - name: POSTGRES_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: allocation-rds-instance-output
                    key: postgres_password
              - name: POSTGRES_NAME
                valueFrom:
                  secretKeyRef:
                    name: allocation-rds-instance-output
                    key: postgres_name
              - name: POSTGRES_USER
                valueFrom:
                  secretKeyRef:
                    name: allocation-rds-instance-output
                    key: postgres_user
          restartPolicy: OnFailure
