liveBook · Manning

Pod

As explained in Road to Kubernetes

A Kubernetes Pod is the smallest deployable workload unit and groups one or more containers with shared network and storage resources.

A Pod is the smallest configurable unit for running containers in Kubernetes. It includes the configuration a container needs; it can also contain multiple containers that share resources. You can create a Pod directly, but a Deployment is the usual choice when you need Kubernetes to manage several Pods. section 8.1.3 section 8.3.1

Run a first Pod

To run one NGINX container, save a YAML manifest as my-first-pod.yaml. Set apiVersion to v1, kind to Pod, metadata.name to first-pod-nginx, and spec.containers to a container named nginx using the nginx image. Run kubectl apply -f my-first-pod.yaml, then kubectl get pods to check that it was created. Run kubectl delete -f my-first-pod.yaml when you no longer need it. section 8.3.1

Listing 8.3 K8s YAML manifest for an NGINX Pod
apiVersion: v1
kind: Pod
metadata:
  name: first-pod-nginx
spec:
  containers:
  - name: nginx
    image: nginx

The complete minimal manifest shows where the Pod name and container image go. section 8.3.1

For multiple instances, put the Pod specification inside a Deployment template. The Deployment declares a replica count and matching labels; a Service can then distribute traffic to available, ready Pods. Deployment-managed Pods are interchangeable and ephemeral: if you delete one, Kubernetes creates another to restore the desired replica count. Find them by label rather than relying on a particular Pod name. section 8.3.3 section 8.4

A directly created, temporary Pod is useful for a quick test inside a cluster—for example, installing a PostgreSQL client to test a database connection. For resources you intend to provision repeatedly, use YAML manifests. section 8.4.3

How Road to Kubernetes covers it

How deep it goes
Works through Pod manifest fields and kubectl commands, then explains Deployment templates, replica counts, and replacement of ephemeral Pods.
Examples
Uses an NGINX Pod manifest, a 15-replica NGINX Deployment, and a temporary Pod for testing a PostgreSQL connection.
What it assumes
Introduces Pods from container and cluster definitions, then supplies the manifest fields needed for a first deployment.
What you can do after
Operate/configure it with a YAML manifest and kubectl to create, inspect, and delete a Pod.
How it connects
Connects Pods to containers, Deployments, Services, labels, and replica counts.

Also explained in

Compare how 15 books explain pod →

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.