liveBook · Manning

Parallelism field

As explained in Kubernetes in Action, Second Edition

The parallelism field is a Job specification field that limits the number of pods allowed to run concurrently for the Job.

The parallelism field limits how many Pods a Job may run at the same time. It controls concurrency, not the total number of successful completions. section 18.1.2

Run five completions with two Pods at once

Set completions to 5 and parallelism to 2. The Job starts two Pods, creates replacements as they finish, and completes after five Pods succeed. section 18.1.2

Interpret parallelism together with completions:

  • Leave both fields unset to create one Pod and require one successful completion. section 18.1.2
  • Set parallelism higher than completions to create only the required number of Pods. section 18.1.2
  • Set parallelism lower than completions to maintain that concurrency while additional Pods replace completed ones. section 18.1.2
  • Use parallelism without completions when one successful Pod completes the Job, while several Pods may run concurrently. section 18.1.2

For work queues, parallelism controls how many Pods retrieve and process work items concurrently. A value of 3 lets three Pods process separate items at once; the container must implement queue retrieval. section 18.1.5 section 18.3

Listing 18.3 A Job for running a task multiple times
apiVersion: batch/v1             #1
kind: Job                       #1
metadata:                       #1
  name: generate-responses      #1
  labels:
    app: quiz
spec:
  completions: 5      #2
  parallelism: 2      #3
  template:
    metadata:
      labels:
        app: quiz
    spec:
      restartPolicy: OnFailure
      containers:
      - name: mongo
        image: mongo:5
        command:
        ...

Inspect the complete Job manifest showing parallelism alongside completions, the Pod template, and restart policy. section 18.1.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains defaults, interaction with completions, replacement behavior, and queue usage without detailing controller internals.
Examples
Demonstrates five completions with parallelism 2 and six queued work items processed with parallelism 3.
What it assumes
Assumes familiarity with Jobs and Pods while defining parallelism and its relationship to completions.
What you can do after
Configure Jobs with a concurrency limit and verify running or completed Pods with kubectl.
How it connects
Connects parallelism to Jobs, Pods, completions, Job controllers, and work queues.

Also explained in

Compare how 2 books explain parallelism field →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.