Jobs & CronJobs
A one-shot Job and a nightly CronJob that pass Kestrel’s admission rules. Commit them to the path your ArgoCD Application syncs (for example manifests/batch/) and replace <tenant>.
Before you start:
- Create the namespace:
kubectl create namespace <tenant>-batch. - Create the PVCs the manifests mount (
input-data,output-data,tenant-data,report-output). See Persistent volumes.
What the manifests set, and why:
securityContext: the PodSecurityrestrictedfields that Kyverno enforces on every Pod.readOnlyRootFilesystemis optional hardening, which is why/tmpis anemptyDir.fsGroup: a fresh Cinder volume isroot:root 0755, so without it a non-root Pod getsPermission deniedwriting to the PVC.priorityClassName: the Job usesuber-user-preempt-medium(preempts lower-priority Pods); the CronJob usesuber-user-significant(never preempts other Pods). See Priority classes.resources: requests and limits count against your tenant’s quota. See Quotas.
Script ConfigMap
Section titled “Script ConfigMap”The scripts are mounted from ConfigMaps, not baked into python:3.12-slim. Commit this next to the Job, and a report-script ConfigMap with a report.py key next to the CronJob.
apiVersion: v1kind: ConfigMapmetadata: name: process-script namespace: <tenant>-batchdata: process.py: | # Replace with your real processing logic from pathlib import Path
files = list(Path("/data/input").iterdir()) for f in files: (Path("/data/output") / f.name).write_bytes(f.read_bytes()) print(f"processed {len(files)} files")apiVersion: batch/v1kind: Jobmetadata: name: process-2026-q2 # change the name to run again namespace: <tenant>-batchspec: backoffLimit: 1 activeDeadlineSeconds: 3600 template: metadata: labels: job: process-2026-q2 spec: restartPolicy: Never priorityClassName: uber-user-preempt-medium securityContext: runAsNonRoot: true runAsUser: 1000 fsGroup: 1000 # makes the Cinder PVC writable for UID 1000 fsGroupChangePolicy: OnRootMismatch seccompProfile: type: RuntimeDefault containers: - name: worker image: python:3.12-slim command: ['python', '/app/process.py'] securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: [ALL] resources: requests: cpu: 500m memory: 1Gi limits: cpu: 2 memory: 4Gi volumeMounts: - name: input mountPath: /data/input readOnly: true - name: output mountPath: /data/output - name: tmp mountPath: /tmp - name: app mountPath: /app readOnly: true volumes: - name: input persistentVolumeClaim: claimName: input-data - name: output persistentVolumeClaim: claimName: output-data - name: tmp emptyDir: {} - name: app configMap: name: process-scriptA Job’s Pod template is immutable, so editing a synced Job fails to sync. To run it again, change metadata.name and push. Don’t set ttlSecondsAfterFinished on a Job that ArgoCD manages: once the TTL deletes it, an Application with selfHeal recreates it and it runs again. Completed Pods don’t count against quota.
CronJob
Section titled “CronJob”apiVersion: batch/v1kind: CronJobmetadata: name: nightly-report namespace: <tenant>-batchspec: schedule: "0 3 * * *" timeZone: "UTC" # or an IANA zone such as America/Vancouver concurrencyPolicy: Forbid successfulJobsHistoryLimit: 3 failedJobsHistoryLimit: 1 jobTemplate: spec: backoffLimit: 1 activeDeadlineSeconds: 1800 template: spec: restartPolicy: OnFailure priorityClassName: uber-user-significant securityContext: runAsNonRoot: true runAsUser: 1000 fsGroup: 1000 # makes the Cinder PVC writable for UID 1000 fsGroupChangePolicy: OnRootMismatch seccompProfile: type: RuntimeDefault containers: - name: reporter image: python:3.12-slim command: ['python', '/app/report.py'] securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: [ALL] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 1 memory: 2Gi volumeMounts: - name: data mountPath: /data/input readOnly: true - name: reports mountPath: /data/reports - name: tmp mountPath: /tmp - name: app mountPath: /app readOnly: true volumes: - name: data persistentVolumeClaim: claimName: tenant-data - name: reports persistentVolumeClaim: claimName: report-output - name: tmp emptyDir: {} - name: app configMap: name: report-scriptEgress is unrestricted by default, so pulls from external stores work as is. If you add an egress NetworkPolicy, allow the destinations and DNS. See NetworkPolicy.
Verify
Section titled “Verify”kubectl get jobs,pods -n <tenant>-batchkubectl logs -n <tenant>-batch job/process-2026-q2
# Trigger the CronJob now instead of waiting for 03:00kubectl create job nightly-report-manual --from=cronjob/nightly-report -n <tenant>-batchkubectl logs -n <tenant>-batch job/nightly-report-manual -fIf something goes wrong
Section titled “If something goes wrong”Start with kubectl describe job -n <tenant>-batch <job>: Pod creation errors appear in the Job’s events.
| Symptom | Cause and fix |
|---|---|
No Pods; Job events show a validate.kyverno.svc-fail PodSecurity denial | A required securityContext field is missing. Restore it from the manifest above. |
Pod Pending with Insufficient cpu or Insufficient memory | No node has room. This is node capacity, not quota. uber-user-preempt-medium preempts only lower-priority Pods (uber-user-significant, and Pods with no class at priority 0); if there are none, the Pod waits. |
ContainerCreating with FailedMount ... configmap "process-script" not found | Commit the script ConfigMap to the same path. |
ContainerCreating with Multi-Attach error | A Pod on another node still has the ReadWriteOnce claim attached. See Storage classes. |
Permission denied writing to /data/output | fsGroup is missing from the Pod securityContext. |
| External endpoint times out | An egress NetworkPolicy selects the Pods without allowing the destination or DNS. See NetworkPolicy. |
| CronJob never runs | kubectl describe cronjob nightly-report -n <tenant>-batch shows Last Schedule Time. Check the schedule against timeZone. |
Job shows OutOfSync with a field is immutable error | You edited a synced Job. Rename it instead. |
For other messages, see the Troubleshooting index.