Back to Practice
Lab

Advanced Jobs: Indexed and Bounded

Go past completions and parallelism: run an Indexed Job so each Pod owns a shard by index, then make a Job bounded and self-cleaning with activeDeadlineSeconds, backoffLimit, and ttlSecondsAfterFinished.

Your mission

A basic Job runs a Pod to completion. Two knobs — completions (how many successes) and parallelism (how many at once) — get you a work queue. But real batch work needs more control, and the CKAD/CKA both test it.

Indexed completion. With completionMode: Indexed, each of the N Pods is assigned a distinct index (0..N-1), exposed to the container as the env var JOB_COMPLETION_INDEX. Now Pod 0 can process shard 0, Pod 1 shard 1, and so on — static partitioning with no coordination. That's the difference between "run this 4 times" and "run this for each of 4 parts."

Bounding a Job. Left alone, a Job can misbehave: a wedged Pod runs forever, a crash-looping one retries endlessly, and finished Jobs pile up. Three fields fix that:

  • activeDeadlineSeconds — a hard wall-clock ceiling; past it the Job is failed and its Pods killed.
  • backoffLimit — how many Pod failures to tolerate before giving up.
  • ttlSecondsAfterFinished — auto-delete the Job (and its Pods) this long after it finishes, so completed Jobs clean themselves up.

In this lab you run an Indexed Job, then make a second Job bounded and self-cleaning.

Useful aliases

In your terminal, k is aliased to kubectl and completion is configured. The jumpbox also has k9s, jq and yq installed.

Skills you'll put into practice

jobsbatchworkloadsckadcka

Make it your own.

Use this topic as a starting point for a fresh custom scenario.

Create a variation