Write a Job that processes 50 work items with 5 running in parallel.
IntermediateHands-onWrite-a-Kubernetes-manifest tasks
Answer
apiVersion: batch/v1
kind: Job
metadata: { name: process-items }
spec:
completions: 50
parallelism: 5
completionMode: Indexed
backoffLimit: 6
ttlSecondsAfterFinished: 3600
template:
spec:
restartPolicy: Never
containers:
- name: worker
image: myrepo/worker:1.0
command: ["python", "worker.py"]
# each pod reads its index from the JOB_COMPLETION_INDEX env var
Key trick → completionMode: Indexed gives each pod a unique JOB_COMPLETION_INDEX (0–49), so you can shard work without a queue. ttlSecondsAfterFinished garbage-collects the finished Job.
More on Write-a-Kubernetes-manifest tasks
Write a Deployment and Service for an Nginx app with 3 replicas, resources and probes.BeginnerAdd an HPA that scales the Deployment between 3 and 15 pods at 70% CPU.BeginnerFix this broken Deployment YAML.BeginnerWrite a ConfigMap and Secret and inject them as environment variables and as a mounted file.IntermediateWrite an Ingress that routes `/api` to the api service and `/` to the web service with TLS.IntermediateWrite a pod spec with a hardened securityContext.Intermediate