---
    apiVersion: batch/v1beta1
    kind: CronJob
    metadata:
      name: db-refresh-job
    spec:
      schedule: "30 10 * * 0"
      concurrencyPolicy: "Forbid"
      successfulJobsHistoryLimit: 5
      failedJobsHistoryLimit: 3
      jobTemplate:
        spec:
          backoffLimit: 0
          activeDeadlineSeconds: 1200
          template:
            spec:
              securityContext:
                runAsUser: 999
              containers:
              - name: dbrefresh
                image: "postgres:11.4"
                command:
                - /bin/entrypoint.sh
                volumeMounts:
                - name: db-refresh-script 
                  mountPath: /bin/entrypoint.sh
                  readOnly: true
                  subPath: entrypoint.sh
                env:
                - name: DB_NAME
                  valueFrom:
                    secretKeyRef:
                      name: dps-rds-instance-output
                      key: database_name
                - name: DB_USER
                  valueFrom:
                    secretKeyRef:
                      name: dps-rds-instance-output
                      key: database_username
                - name: DB_PASS
                  valueFrom:
                    secretKeyRef:
                      name: dps-rds-instance-output
                      key: database_password
                - name: DB_HOST
                  valueFrom:
                    secretKeyRef:
                      name: dps-rds-instance-output
                      key: rds_instance_address
                - name: DB_NAME_PREPROD
                  valueFrom:
                    secretKeyRef:
                      name: dps-rds-instance-output-preprod
                      key: database_name
                - name: DB_USER_PREPROD
                  valueFrom:
                    secretKeyRef:
                      name: dps-rds-instance-output-preprod
                      key: database_username
                - name: DB_PASS_PREPROD
                  valueFrom:
                    secretKeyRef:
                      name: dps-rds-instance-output-preprod
                      key: database_password
                - name: DB_HOST_PREPROD
                  valueFrom:
                    secretKeyRef:
                      name: dps-rds-instance-output-preprod
                      key: rds_instance_address
              restartPolicy: "Never"
              volumes:
              - name: db-refresh-script
                configMap:
                  name: db-refresh-script
                  defaultMode: 0755