apiVersion: batch/v1beta1
kind: CronJob
metadata:
  namespace: argo-events
  name: cron-ecr-renew
  labels:
    app: ecr-renew
spec:
  schedule: "05 00 * * *"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          serviceAccountName: ecr-renew
          containers:
            - name: ecr-renew
              image: nabsul/k8s-ecr-login-renew:latest
              env:
                - name: DOCKER_SECRET_NAME
                  value: ecr-docker-login
                - name: TARGET_NAMESPACE
                  value: argo-events,dev
                - name: AWS_REGION
                  valueFrom:
                    secretKeyRef:
                      name: ecr-renew-cred
                      key: REGION
                - name: AWS_ACCESS_KEY_ID
                  valueFrom:
                    secretKeyRef:
                      name: ecr-renew-cred
                      key: ID
                - name: AWS_SECRET_ACCESS_KEY
                  valueFrom:
                    secretKeyRef:
                      name: ecr-renew-cred
                      key: SECRET