liveBook · Manning

Pod template

As explained in Road to Kubernetes

A Pod template is the configuration specifying the default metadata and containers for Pods created by a Kubernetes workload resource.

A Pod template defines the metadata and container specification for Pods created by a workload resource. In a Deployment, it reuses the Pod manifest’s metadata and spec without kind or apiVersion. section 8.3.3

A useful Pod template connects three pieces:

  • metadata.labels identifies the Pods and must match the workload’s selector. section 8.3.3
  • spec.containers declares the containers, images, ports, environment, and mounts that each Pod receives. section 8.3.3 section 8.4.2
  • StatefulSets can extend the template with init containers and containers connected to individually provisioned volumes. section 8.4.2
Listing 8.6 K8s YAML manifest for an NGINX Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 15
  selector:
    matchLabels:
      app: my-nginx
  template:
    metadata:
      labels:
        app: my-nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest

This NGINX Deployment shows the template nested under spec, with matching app labels and a container image. section 8.3.3

How Road to Kubernetes covers it

How deep it goes
Explains the template structure through Deployment YAML and extends it to StatefulSet volumes, init containers, and application settings.
Examples
Uses an NGINX Deployment template and a Postgres StatefulSet template with secrets, volume claims, and mounts.
What you can do after
Builds Deployment and StatefulSet manifests with matching selectors, container definitions, and workload-specific storage configuration.
How it connects
Connects Pods with Deployments, StatefulSets, selectors, labels, containers, init containers, and persistent volumes.

Also explained in

Compare how 3 books explain pod template →

Related concepts

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