---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: export-cert-prison-api-stage
spec:
  schedule: "0 10 * * 1-5"
  concurrencyPolicy: "Forbid"
  successfulJobsHistoryLimit: 5
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      backoffLimit: 0
      activeDeadlineSeconds: 1200
      template:
        spec:
          containers:
          - name: hmpps-devops-tools
            image: ghcr.io/ministryofjustice/hmpps-devops-tools
            command:
            - /bin/export-cert.sh
            args:
            - "prison-api-stage" # k8s secret name where letsencrypt cert is stored
            - "nomisapi-t2-certs" # azure keyvault name
            - "prison-api" # azure keyvault certificate name
            volumeMounts:
            - name: export-cert-script
              mountPath: /bin/export-cert.sh
              readOnly: true
              subPath: export-cert.sh
            - name: azure-sp
              mountPath: "/azure/azure-sp"
              readOnly: true
            - name: prison-api-stage
              mountPath: "/certs/prison-api-stage"
              readOnly: true
          restartPolicy: "Never"
          volumes:
          - name: export-cert-script
            configMap:
              name: export-cert-script
              defaultMode: 0755
          - name: azure-sp
            secret:
              secretName: azure-sp-t2
          - name: prison-api-stage
            secret:
              secretName: prison-api-stage
