apiVersion: batch/v1
kind: CronJob
metadata:
  name: servala-clearsessions
spec:
  schedule: "42 02 * * 1"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: servala-clearsessions
              image: servala-2nkgm.app.codey.ch/servala/servala-portal:latest
              imagePullPolicy: Always
              # The command to clear sessions
              command: ["uv", "run", "src/manage.py", "clearsessions"]
              envFrom:
                - secretRef:
                    name: servala
              env:
                - name: SERVALA_DB_USER
                  valueFrom:
                    secretKeyRef:
                      name: database-creds
                      key: POSTGRESQL_USER
                - name: SERVALA_DB_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: database-creds
                      key: POSTGRESQL_PASSWORD
                - name: SERVALA_DB_HOST
                  valueFrom:
                    secretKeyRef:
                      name: database-creds
                      key: POSTGRESQL_HOST
                - name: SERVALA_DB_PORT
                  valueFrom:
                    secretKeyRef:
                      name: database-creds
                      key: POSTGRESQL_PORT
                - name: SERVALA_DB_NAME
                  valueFrom:
                    secretKeyRef:
                      name: database-creds
                      key: POSTGRESQL_DB
                - name: UV_CACHE_DIR
                  value: /app/.uvcache
          restartPolicy: OnFailure
