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