# services/maintenance/pod-cleaner-cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: pod-cleaner
  namespace: maintenance
spec:
  schedule: "0 * * * *"
  suspend: true
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      backoffLimit: 1
      template:
        spec:
          serviceAccountName: pod-cleaner
          restartPolicy: Never
          nodeSelector:
            kubernetes.io/arch: arm64
            node-role.kubernetes.io/worker: "true"
          containers:
            - name: cleaner
              image: bitnami/kubectl@sha256:554ab88b1858e8424c55de37ad417b16f2a0e65d1607aa0f3fe3ce9b9f10b131
              command: ["/usr/bin/env", "bash"]
              args: ["/scripts/pod_cleaner.sh"]
              volumeMounts:
                - name: script
                  mountPath: /scripts
                  readOnly: true
          volumes:
            - name: script
              configMap:
                name: pod-cleaner-script
                defaultMode: 0555
