A static queue assigns a known number of tasks before processing begins. A Kubernetes Job creates a separate Pod for each task, moving task-assignment logic from the worker container into Kubernetes configuration. section 10.3.2
Use a static queue when:
- The total task count is known in advance and can be configured as Job completions. section 10.3.2
- Tasks have natural indexes, allowing each Pod to receive its task number through JOB_COMPLETION_INDEX. section 10.3.2
- The worker should not implement dynamic-queue retrieval, accepting more Kubernetes-side configuration instead. section 10.3.2
Rendering animation frames
Declare 30,000 completions for a 30,000-frame animation. Kubernetes creates Pods and supplies each frame number, letting every worker render its assigned frame. section 10.3.2
Listing 10.13 Chapter10/10.3.2_IndexedJob/indexed_job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: echo
spec:
completions: 5 #1
parallelism: 3 #2
completionMode: Indexed #3
template:
metadata:
labels:
pod: framerender
spec:
restartPolicy: Never
containers:
- name: 'worker'
image: 'docker.io/library/busybox'
command: ["echo", "render frame: $(JOB_COMPLETION_INDEX)"] #4
Inspect the Indexed Job manifest: completions sets the task count, parallelism limits concurrent Pods, and completionMode enables indexed assignments. section 10.3.2
