apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: '${CERTIFICATES_CRONJOB_NAME}'
  namespace: '${NAMESPACE@microservice-config}'
  labels:
    moduleid: microservice-realm
    version: 1.70.7-master
spec:
  schedule: '0 1 * * *'
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            cronjob: '${CERTIFICATES_CRONJOB_NAME}'
        spec:
          serviceAccountName: '${CERTIFICATES_ACCOUNT_NAME}'
          containers:
            -
              name: app
              image: 'repoflow/microservice-certificates-container:1.70.1-master'
              env:
                -
                  name: ENV_MODE
                  value: production
                -
                  name: NAMESPACE
                  value: '${NAMESPACE@microservice-config}'
                -
                  name: DOMAIN
                  value: '${DOMAIN@microservice-config}'
                -
                  name: EMAIL
                  value: '${ADMIN_EMAIL@microservice-config}'
                -
                  name: SSL_SECRET_NAME
                  value: '${CERTIFICATES_SECRET_NAME}'
                -
                  name: AWS_ACCESS_KEY_ID
                  valueFrom: {secretKeyRef: {name: '${CERTBOT_SECRET_NAME}', key: aws.key.id}}
                -
                  name: AWS_SECRET_ACCESS_KEY
                  valueFrom: {secretKeyRef: {name: '${CERTBOT_SECRET_NAME}', key: aws.secret.key}}
              volumeMounts:
                -
                  mountPath: /certificates
                  name: data
          restartPolicy: OnFailure
          volumes:
            -
              name: data
              persistentVolumeClaim:
                claimName: '${CERTIFICATES_CLAIM_NAME}'
