liveBook · Manning

Pod specification

As explained in Kubernetes for Developers

A PodSpec is the Kubernetes specification that defines the containers and settings of a Pod.

A PodSpec is the Kubernetes specification for a Pod’s containers and settings. It identifies each container and its image, and can also define health checks, resource requirements, environment variables, and restart behavior. section 3.2.4 section 10.2.1

Kubernetes embeds PodSpecs inside higher-order objects such as Deployments, StatefulSets, and Jobs. A Deployment controller uses the embedded specification to create and manage Pods; a Job uses it to run a task in its own Pod. section 3.2.4 section 10.2.1

Choose how to use a PodSpec based on the required lifecycle:

  • Embed it in a Deployment or another controller when Pods need replacement or rescheduling after eviction or node failure. section 3.2.4
  • Create it as a standalone Pod for direct execution, accepting that crashes trigger reboot but eviction does not trigger rescheduling. section 3.2.4
  • Embed it in a Job for one-off work, using restartPolicy and the Job’s backoffLimit to control retries. section 10.2.1

A minimal standalone PodSpec

A Pod manifest can place the PodSpec directly under spec: apiVersion: v1, kind: Pod, metadata for the name and labels, then spec.containers with a container name and image such as docker.io/wdeniss/timeserver:1. Apply it with kubectl, but use a controller when eviction recovery matters. section 3.2.4

How Kubernetes for Developers covers it

How deep it goes
Explains composition, lifecycle consequences, container fields, and Job retry settings, but not the complete API field reference.
Examples
Uses a timeserver Pod manifest and an addwork Job with commands, environment variables, restartPolicy, and backoffLimit.
What you can do after
Apply it via kubectl as a standalone Pod or embedded template, while choosing controller-managed recovery when required.
How it connects
Connects PodSpec with Pods, Deployments, StatefulSets, Jobs, Services, containers, kubelet, and resource requirements.

Also explained in

Compare how 2 books explain pod specification →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes for Developers. The section links point to the parts of the book it draws on.