apiVersion: batch/v1
kind: CronJob
metadata:
  name: update-expired-courses
spec:
  schedule: "0 0 1 * *"
  concurrencyPolicy: Forbid
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 3
  jobTemplate:
    spec:
      activeDeadlineSeconds: 3600
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: update-expired-courses
              image: ${BACKEND_IMAGE}
              command: ["npm", "run", "update-expired-courses"]
              resources:
                requests:
                  memory: "500Mi"
              env:
                - name: REDIS_HOST
                  value: "quizzes-backend-redis-master.default.svc.cluster.local"
                - name: REDIS_PORT
                  value: "6379"
                - name: REDIS_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: quizzes-backend-redis
                      key: redis-password
                - name: DB_NAME
                  valueFrom:
                    secretKeyRef:
                      name: backend-database-secret
                      key: POSTGRES_DATABASE
                - name: DB_HOST
                  valueFrom:
                    secretKeyRef:
                      name: backend-database-secret
                      key: POSTGRES_HOST
                - name: DB_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: backend-database-secret
                      key: POSTGRES_PASSWORD
                - name: DB_USER
                  valueFrom:
                    secretKeyRef:
                      name: backend-database-secret
                      key: POSTGRES_USERNAME
                - name: TMC_TOKEN
                  valueFrom:
                    secretKeyRef:
                      name: backend-database-secret
                      key: TMC_TOKEN
