Read a pod.yaml and follow a pod's lifecycle

DevOps, Hands On25 minutesFreeSteps checked 23 November 2026By Cloud Hands On

In this task you'll read any pod definition and follow a pod from creation to finish.

A pod.yaml has four parts: apiVersion and kind (what it is), metadata (name, namespace and labels that services and deployments select on), and spec (what to run). In the spec, each container has an image, ports, env, resources (requests and limits), probes and volumeMounts.

A pod moves through phases: Pending (accepted, but not all containers are running; often still scheduling or pulling images), Running, then Succeeded or Failed, or Unknown if its node can't be reached. Each container also has a state (Waiting, Running or Terminated) with a reason, and that reason (such as CrashLoopBackOff) is usually the clue you need.

Example. Quayhurst Health's appointment API stayed Pending after a release. Reading the pod.yaml showed a memory request of 64Gi (a typo for 64Mi); no node had that much free, so the scheduler couldn't place it.

Before you start

You need: Docker Desktop and kind on your computer (both free). Time: 25 minutes.

Where to look

  1. Terminal
  2. kubectl

Steps

  1. Run kubectl run demo --image=nginx --dry-run=client -o yaml > pod.yaml and read each section of the file.
  2. Add resources (requests and limits) and a readinessProbe on port 80, then kubectl apply -f pod.yaml.
  3. Watch it with kubectl get pod demo -w and note the phase changes.
  4. Run kubectl describe pod demo and read the Conditions and Events at the bottom.
  5. Use kubectl explain pod.spec.containers.resources whenever you don't know what a field means.

Commands

kubectl run demo --image=nginx --dry-run=client -o yaml > pod.yaml
kubectl apply -f pod.yaml
kubectl get pod demo -o jsonpath='{.status.phase}{"\n"}'
kubectl describe pod demo
kubectl explain pod.spec.containers.resources

Watch out for

Cost
Free on kind.
Security
Read every pod.yaml for privileged, hostPath and runAsUser: 0 before you apply it.
Common mistakes
Running bare pods in production: use a Deployment so a controller replaces pods that die.

Clean up

kubectl delete pod demo.

Words to know

Pod phase
The pod's overall stage: Pending, Running, Succeeded, Failed or Unknown.
Container state
Each container's status (Waiting, Running or Terminated) with a reason such as CrashLoopBackOff.
Probe
A check the kubelet runs on a container: startup, readiness or liveness.
Label selector
How services and deployments find their pods, by matching labels.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going