A Kubernetes Pod drawn as a capsule that holds 3 containers and a shared volume, with 1 network connection
DevOps Engineering

Kubernetes Pod: What It Is, Lifecycle, YAML and Debugging

What a Kubernetes Pod is, its 5 phases, a production YAML, how it shuts down and 8 statuses to debug.

Michael Zion

17 min read

A Kubernetes Pod is 1 or more containers that share 1 IP address and 1 set of volumes. It is the smallest thing Kubernetes can run. 5 things to know before you run one:

Bottom line

  1. Pod = a wrapper around your containers. Kubernetes schedules, starts and stops Pods. It manages your containers through them
  2. Most Pods hold 1 container. A second container belongs in the same Pod only when the 2 are tightly coupled, like an app and its log shipper
  3. You rarely create a Pod yourself. A Deployment, StatefulSet, DaemonSet or Job creates Pods from a template and replaces the ones that die
  4. A Pod is NEVER moved to another node. It is deleted and a new Pod takes its place, with a new UID and usually a new IP
  5. The STATUS column in kubectl is a hint. A Pod has 5 phases. CrashLoopBackOff, ImagePullBackOff and Terminating are display values that kubectl puts on top of them

A small Pod that works, on Kubernetes v1.37:

apiVersion: v1
kind: Pod
metadata:
  name: web
  labels:
    app: web
spec:
  containers:
  - name: web
    image: nginx:1.29
    ports:
    - containerPort: 80

The 5 commands you will use most:

kubectl apply -f pod.yaml
kubectl get pods -o wide
kubectl describe pod web
kubectl logs web
kubectl exec -it web -- sh

Pods that restart all night, or sit in Pending while the release waits? Get a free DevOps assessment: a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup.

Find your situation:

A Pod is a wrapper around your containers

Kubernetes does not run containers directly. It runs Pods, and each Pod runs your containers.

Pod = 1 or more containers + 1 IP address + shared volumes + a spec for how to run them.

What the containers in a Kubernetes Pod share: a Pod with 2 containers, an app and a log shipper, that talk over localhost, share volumes and have 1 IP address, while each container keeps its own filesystem
1 IP address, shared volumes, and localhost between the containers.

The containers in a Pod always land on the same node and are scheduled together.

What they share:

  • The network: 1 IP address and 1 port space. Containers in the same Pod reach each other on localhost, so 2 of them cannot listen on the same port
  • The volumes: every volume of the Pod can be mounted by every container in it
  • The hostname: each container sees the Pod name as its hostname, unless you set another one
  • The lifetime: they start on the same node and they are deleted together

What they keep to themselves:

  • The filesystem: each container sees the root filesystem of its own image. A volume has to be mounted in each container that needs it
  • Requests and limits: CPU and memory are set per container
  • The process list: a container sees only its own processes, unless you set shareProcessNamespace: true

The docs call a Pod a "logical host". I find that the simplest way to think about it: a Pod is a tiny machine that runs 1 app.

Want more copies of the app? Run more Pods. Adding copies as extra containers inside 1 Pod is the wrong direction.

Pod vs container, node, cluster and Deployment

These 5 words get mixed up in every first week with Kubernetes.

ThingWhat it isRelation to a Pod
Container1 running image with your software and its dependenciesLives inside a Pod
Pod1 or more containers with a shared IP and volumesThe unit Kubernetes schedules
NodeA worker machine, virtual or physicalRuns many Pods
ClusterA set of nodes plus a control planeDecides which node gets each Pod
DeploymentAn object that manages a replicated appCreates the Pods and replaces them

Container inside Pod, Pod on node, node in cluster.

Why you create Deployments and let them create Pods

A Pod you create by hand is called a bare Pod. Nothing watches it.

What happens to a bare Pod when its node dies:

  1. The node stops reporting
  2. After about 6 minutes Kubernetes marks the Pod for deletion
  3. The Pod shows Terminating until the node comes back or is removed from the cluster
  4. Nothing creates a new one

A Deployment holds a Pod template and a replica count. When a Pod disappears for any reason, it creates a replacement from the template.

My rule: a bare Pod is for a 5 minute test. Everything else gets a controller, even when you need exactly 1 copy.

Your workloadWhat creates the Pods
A stateless app or APIDeployment
A database or anything that needs a stable name and diskStatefulSet
An agent that runs on every nodeDaemonSet
A task that runs once and exitsJob
A task on a scheduleCronJob

One exception: static Pods. The kubelet on a node reads them from a directory on disk and runs them without the API server. kubeadm runs the control plane itself this way (kube-apiserver, etcd, kube-scheduler, kube-controller-manager).

A Pod YAML you can copy

The small manifest at the top runs. This one is shaped for production.

In real life the part under spec goes into the template of a Deployment.

apiVersion: v1
kind: Pod
metadata:
  name: web
  labels:
    app: web
spec:
  automountServiceAccountToken: false
  terminationGracePeriodSeconds: 30
  securityContext:
    runAsNonRoot: true
    runAsUser: 10001
    fsGroup: 10001
    seccompProfile:
      type: RuntimeDefault
  containers:
  - name: web
    image: registry.example.com/web:1.4.2
    ports:
    - name: http
      containerPort: 8080
    resources:
      requests:
        cpu: 250m
        memory: 256Mi
      limits:
        memory: 256Mi
    startupProbe:
      httpGet:
        path: /healthz
        port: http
      periodSeconds: 2
      failureThreshold: 30
    readinessProbe:
      httpGet:
        path: /ready
        port: http
    livenessProbe:
      httpGet:
        path: /healthz
        port: http
    lifecycle:
      preStop:
        sleep:
          seconds: 5
    securityContext:
      allowPrivilegeEscalation: false
      readOnlyRootFilesystem: true
      capabilities:
        drop: ["ALL"]
    volumeMounts:
    - name: tmp
      mountPath: /tmp
  volumes:
  - name: tmp
    emptyDir:
      sizeLimit: 64Mi

What each block is for:

  • A fixed image tag: with :latest or no tag, Kubernetes asks the registry on every start and downloads whatever changed. So the same manifest can run different code tomorrow. With any other tag it pulls only when the image is missing on the node. The policy is set when the Pod is created and stays
  • Requests: the scheduler places the Pod by its requests. Real usage plays no part in that math
  • A memory limit equal to the request: the container can never use more memory than the scheduler counted for it. I leave the CPU limit off, because a CPU limit throttles the app even when the node has spare CPU
  • 3 probes: startup gives a slow boot up to 60 seconds, readiness takes the Pod out of traffic, liveness restarts a stuck container. Their defaults: every 10 seconds, 1 second timeout, 3 failures
  • preStop sleep: 5 seconds for load balancers to stop sending traffic before the app gets the stop signal
  • The security block: allowPrivilegeEscalation defaults to true, so you have to turn it off yourself. A read-only root filesystem needs an emptyDir for every path the app writes to
  • No API token: by default a Pod gets a service account token mounted. An app that never calls the Kubernetes API does not need one

Go deeper on 2 of these: liveness probes without restart loops and requests and limits without throttling.

The Pod lifecycle: 5 phases and what kubectl shows

A Pod has exactly 5 phases.

PhaseWhat it means
PendingAccepted by the cluster, and at least 1 container is not ready to run. Covers waiting for a node and pulling images
RunningBound to a node, all containers created, at least 1 is running, starting or restarting
SucceededAll containers exited with success and will not restart
FailedAll containers stopped and at least 1 failed
UnknownThe node cannot be reached, so the state is unknown
The 5 Kubernetes Pod phases: Pending while waiting for a node and pulling images, Running when at least 1 container is running, then Succeeded or Failed, and Unknown when the node cannot be reached
5 phases. Everything else kubectl shows is a display value.

The happy path:

You apply the manifest
โ†’ the scheduler binds the Pod to a node (once in its lifetime)
โ†’ the kubelet sets up the sandbox and the network
โ†’ init containers run, 1 at a time
โ†’ images are pulled and the app containers start
โ†’ the readiness probe passes
โ†’ the Pod is Ready and gets traffic

Each container inside the Pod has its own state: Waiting, Running or Terminated.

STATUS in kubectl is a display column

Run kubectl get pods and you will see words that are missing from the table above.

CrashLoopBackOff, ImagePullBackOff, ContainerCreating, Completed, Terminating: kubectl builds these from the phase, the container states and their reasons.

A Pod in CrashLoopBackOff is usually in phase Running.

So when a script needs the real phase, ask for it:

kubectl get pod web -o jsonpath='{.status.phase}'

The Pod also carries conditions that tell you how far it got: PodScheduled โ†’ PodReadyToStartContainers โ†’ Initialized โ†’ ContainersReady โ†’ Ready.

kubectl describe pod prints them. Read them in the order above: the first one that is False is where the Pod is stuck.

What happens when a container crashes

The kubelet restarts the container inside the same Pod, on the same node. The Pod stays.

Restarts follow restartPolicy: Always (the default), OnFailure or Never. A Deployment only accepts Always. Jobs use OnFailure or Never.

The timing of the restarts:

  • First crash: restarted immediately
  • After that the wait doubles: 10 seconds, 20, 40 and so on
  • The wait is capped at 300 seconds (5 minutes)
  • After 10 minutes of running clean, the counter resets

CrashLoopBackOff = the container keeps failing, and Kubernetes is waiting before the next try.

It tells you that the container fails. Why it fails is in the logs of the run that died:

kubectl logs web --previous
kubectl describe pod web

The usual causes: an app error at startup, a wrong config, a missing environment variable, too little memory, or a liveness probe that kills a healthy app.

Since v1.35 a node can lower the 5 minute cap out of the box (crashLoopBackOff.maxContainerRestartPeriod in the kubelet configuration, between 1 and 300 seconds).

Init containers and sidecars: when 1 Pod needs more than 1 container

The docs call a multi-container Pod "a relatively advanced use case". I agree.

My test for a second container: does it have to share the network or the disk of the first one? If the answer is no, it gets its own Pod.

TypeWhen it runsUse it for
Init containerBefore the app, 1 at a time, each to completionMigrations, waiting for a dependency, fetching config
Sidecar containerStarts before the app and runs for the whole life of the PodLog shippers, proxies, secret agents
Ephemeral containerAdded to a running Pod by kubectl debugDebugging an image that has no shell

3 facts about init containers:

  1. They run in the order they are written, and each one must succeed before the next one starts
  2. A failing init container is retried until it succeeds (with restartPolicy: Never the whole Pod fails)
  3. They can run more than once, so the code in them has to be safe to repeat

A sidecar is written as an init container with restartPolicy: Always. This is stable since v1.33:

spec:
  initContainers:
  - name: log-shipper
    image: registry.example.com/log-shipper:2.1.0
    restartPolicy: Always
  containers:
  - name: web
    image: registry.example.com/web:1.4.2

What you get from it:

  • The sidecar starts before the app
  • It is stopped after the app, so the last log lines still ship
  • In a Job it no longer blocks completion when the main container finishes

If you still run sidecars as regular containers with wrapper scripts to fix the start order, this replaces all of it.

Requests, limits and what happens when a Pod goes over

Request = what the scheduler reserves for the container. Limit = the most it is allowed to use.

The container goes over itsWhat happens
CPU limitIt is throttled. It is never killed for CPU
Memory limitThe kernel can kill the container. kubectl describe pod shows Reason: OOMKilled and Exit Code: 137
Memory request, on a node that runs shortThe Pod becomes a likely candidate for eviction

Two details that surprise people:

  • The memory kill is reactive. It happens when the kernel detects memory pressure, so a container can sit above its limit for a moment
  • The kernel kills the processes of that container. The Pod stays, the container restarts, and its restart count goes up by 1

Kubernetes also gives every Pod a quality of service class, from its requests and limits:

ClassRule
GuaranteedEvery container has CPU and memory requests equal to its limits
BurstableAt least 1 request or limit is set, and the Pod misses the Guaranteed rule
BestEffortNo requests and no limits at all

When a node runs out of memory or disk, the kubelet evicts Pods. Pods that use more than they requested go first. Among those, the lowest priority goes first, then the one furthest above its request.

A BestEffort Pod requests 0, so any usage puts it above its request. It is always in the first group.

An evicted Pod gets no grace period at a hard threshold, and PodDisruptionBudgets are ignored. (The Pod does not get a vote.)

If you set a limit and no request, Kubernetes copies the limit into the request (unless a LimitRange in the namespace sets a default request).

Change CPU and memory without a restart

Since v1.35, in-place resize is stable. You can change the CPU and memory of a running Pod:

kubectl patch pod web --subresource resize --patch \
  '{"spec":{"containers":[{"name":"web","resources":{"requests":{"cpu":"500m"}}}]}}'

It needs kubectl v1.32 or later. Only CPU and memory can be resized, and the quality of service class of the Pod cannot change.

So this works on a Pod that already has requests, like the production manifest above. The small Pod at the top has none, and Kubernetes rejects the resize.

Remember that a Deployment will not know about it. Change the template too, or the next rollout brings the old values back.

How a Pod shuts down in 30 seconds

Every deploy, scale-down and node drain deletes Pods. Most failed requests during a deploy come from this sequence.

You delete the Pod (or a rollout does)
โ†’ the Pod is marked as terminating
โ†’ at the same time, Services start to take it out of rotation and the preStop hook runs, if there is one
โ†’ the kubelet sends SIGTERM to the main process of each container
โ†’ the app finishes its open requests and exits
โ†’ after 30 seconds, whatever still runs gets SIGKILL

30 seconds is the default of terminationGracePeriodSeconds.

How a Kubernetes Pod shuts down: the Pod is deleted and stops getting new traffic, the preStop hook runs, SIGTERM is sent, the app finishes open requests, and SIGKILL follows after 30 seconds by default
The preStop hook and the app share the same 30 seconds.

3 things go wrong here:

  1. The app ignores SIGTERM. It keeps serving for 30 seconds and is then killed in the middle of a request. Catch the signal and shut down
  2. The app exits too fast. Removing the Pod from load balancers and sending SIGTERM happen in parallel, so some requests still arrive. A preStop sleep of a few seconds covers the gap
  3. The preStop hook eats the budget. The time it takes counts against the 30 seconds. A 25 second sleep leaves the app 5 seconds

Also good to know: the preStop hook does not run when a container crashes or exits by itself. It runs only when Kubernetes stops the container.

And the force delete:

kubectl delete pod web --grace-period=0 --force

This removes the Pod from the API right away, without waiting for the node to confirm. The processes can keep running on the node. Use it for a Pod on a node that is gone, and stay away from it for databases.

For whole nodes, see how to drain nodes without evicting critical workloads.

A Pod is never moved, it is replaced

A Pod is scheduled once. It stays on that node until it finishes, is deleted, is evicted, or the node fails.

"The Pod moved to another node" always means: the old Pod was deleted and a controller created a new one.

A Kubernetes Pod is never moved, it is replaced: the old Pod on the failed node 1 is deleted and the Deployment creates a new Pod on node 2 with a new UID and a new IP
Same template, new Pod, new UID, new IP.

What the new Pod gets:

  • A new UID (the name can stay, as in a StatefulSet)
  • A new IP address, in almost every setup
  • An empty emptyDir. That volume lives exactly as long as the Pod
  • The same PersistentVolumeClaim, when the workload uses one

This is why nothing should call a Pod by its IP. A Service gives a changing set of Pods 1 stable address.

And it is why a dead node hurts for about 6 minutes. Kubernetes waits 50 seconds before it marks the node as unreachable. Then a second timer starts: a Pod gets 2 tolerations added automatically, for nodes that are not ready or unreachable, with tolerationSeconds: 300 (unless you set your own). The Pods stay bound to the dead node for those 300 seconds before they are evicted and replaced.

If 6 minutes is too long for a service, lower tolerationSeconds in its Pod template and run more than 1 replica across nodes.

How many Pods fit on a node

Kubernetes is designed for 110 Pods per node, and 110 is the default of the kubelet setting maxPods.

The cloud providers change that number, mostly because of IP addresses:

PlatformPods per nodeWhat drives it
Upstream default110The kubelet setting maxPods
Amazon EKSComputed per instance type, capped at 110 under 30 vCPUs and 250 above (managed node groups)Network interfaces and IPs per interface
GKE Standard110 by default, up to 512The Pod IP range given to each node
GKE AutopilotChosen by Google, between 8 and 256Set for you and fixed
AKSUp to 250. Default 250 with Azure CNI Overlay, 110 with kubenet (30 when created in the portal), 30 with legacy Azure CNIThe network plugin

On EKS each Pod takes an IP address from your VPC. The formula for the default is:

max Pods = network interfaces ร— (IPs per interface - 1) + 2

So a small instance can run out of Pod IPs while half of its CPU is free. Prefix delegation raises the ceiling.

On GKE Standard the number is set when the cluster or node pool is created and cannot be changed later. Decide it before you create the pool.

Debug a Pod: 8 statuses and the first command for each

Start every time with the same command. It shows the container states, the restart count and the recent events:

kubectl describe pod web

Then go by what the STATUS column says.

STATUSWhat it meansDo this first
PendingNo node accepts the Pod. The event says FailedScheduling with a reason like "Insufficient cpu"Read the event. Lower the requests, add nodes, or fix the taint or selector that excludes them
ContainerCreatingScheduled, and the node is still preparing the network, the volumes or the imageRead the events for a volume that cannot mount or a missing Secret
ImagePullBackOffThe image cannot be pulled. Kubernetes retries with a growing wait, up to 5 minutesCheck the image name and tag, then the imagePullSecrets for a private registry
CrashLoopBackOffThe container starts and dies, again and againkubectl logs web --previous
Running, 0/1 readyThe container runs and the readiness probe fails, so the Pod gets no trafficRead the probe failures in the events, then call the probe path yourself
Init:0/2The Pod has 2 init containers and none has finishedkubectl logs web -c NAME with the name of the init container
EvictedThe node ran short of memory or disk and the kubelet removed the PodSet requests that match real usage. Check what else runs on that node
Terminating (stuck)Deletion was requested and something blocks it, most often a finalizer or a node that stopped answeringkubectl get pod web -o yaml and read metadata.finalizers

A ninth one you will meet: CreateContainerConfigError. The events name the ConfigMap or Secret the container asks for and cannot find.

The commands that go with the table:

# Which node, which IP, how many restarts
kubectl get pods -o wide

# Events for 1 Pod only
kubectl events --for pod/web

# Logs: follow, the crashed run, every container
kubectl logs web -f
kubectl logs web --previous
kubectl logs web --all-containers

# Real CPU and memory use (needs metrics-server)
kubectl top pod web --containers

# Call the app from your laptop (local port:container port)
kubectl port-forward pod/web 8080:8080

# What does this field do
kubectl explain pod.spec.containers.resources

The image has no shell? Add a debug container to the running Pod:

kubectl debug -it web --image=busybox:1.36 --target=web

--target puts the debug container in the process namespace of the web container, so you see its processes.

The container dies too fast to look at? Copy the Pod with a shell as its command:

kubectl debug web -it --copy-to=web-debug --container=web -- sh

More one-liners in the kubectl cheat sheet.

What changed for Pods from v1.33 to v1.37

Most Pod guides were written before these. If your knowledge of Pods is 2 years old, this table is the update.

VersionChange
v1.33Native sidecar containers are stable
v1.35In-place resize of CPU and memory is stable
v1.35cgroup v1 is retired: the kubelet refuses to start on a cgroup v1 node by default
v1.35Restart rules per container (restartPolicyRules by exit code) are beta and on by default
v1.36User namespaces are stable. With hostUsers: false, root in the container is an unprivileged user on the node
v1.36Image volumes are stable: mount an OCI image as a read-only volume
v1.36A Pod can restart all its containers in place and keep its UID and IP (beta, through restartPolicyRules)
v1.36The gitRepo volume type is disabled for good
v1.37Static Pods can no longer reference Secrets or ConfigMaps

Coming next: resources set for the whole Pod (spec.resources) are beta since v1.34 and expected to become stable in v1.38.

Checklist before a Pod goes to production

Always:

  • A controller owns the Pod (Deployment, StatefulSet, DaemonSet or Job)
  • The image has a fixed tag or a digest
  • Every container has CPU and memory requests
  • Every container has a memory limit
  • A readiness probe exists and checks what the app needs to serve
  • The liveness probe checks only the app itself, with no calls to dependencies
  • The app handles SIGTERM and exits within the grace period
  • A preStop sleep covers the load balancer delay
  • runAsNonRoot: true and allowPrivilegeEscalation: false
  • All capabilities dropped, seccomp profile RuntimeDefault
  • The service account token is off when the app does not call the API
  • More than 1 replica, spread across nodes
  • Nothing stores data in the container filesystem or in an emptyDir that you cannot lose

FAQ

What is a Pod in Kubernetes?

A Pod is the smallest unit Kubernetes can deploy: 1 or more containers that share an IP address, volumes and a spec. Kubernetes schedules Pods onto nodes and manages containers through them.

What is the difference between a Pod and a container?

A container is 1 running image. A Pod is the wrapper Kubernetes puts around 1 or more containers so they share a network and volumes and are scheduled as 1 unit.

What is the difference between a Pod and a node?

A node is a machine. A Pod is a workload that runs on that machine. 1 node runs many Pods, up to 110 by default.

Can a Pod have more than 1 container?

Yes. Use it when the containers must share the network or a volume: an app with a log shipper or a proxy. Separate services go in separate Pods so they can scale on their own.

What is the difference between a Pod and a Deployment?

A Pod is 1 running copy of your app. A Deployment holds the template and the replica count, creates the Pods, replaces the ones that die and rolls out new versions.

How do I restart a Pod?

You do not restart a Pod, you replace it. For a Deployment run kubectl rollout restart deployment/web, or delete the Pod with kubectl delete pod NAME and let the controller create a new one.

Why is my Pod stuck in Pending?

No node can take it. kubectl describe pod shows a FailedScheduling event with the reason: too little CPU or memory for the requests, a taint without a toleration, or a node selector that matches no node.

What does exit code 137 mean?

The container was killed with SIGKILL. Together with Reason: OOMKilled it means the kernel killed it for memory. Most of the time the container went over its own limit, and sometimes the whole node ran out. Look for a leak, or raise the limit.

A recap

If you take away 1 thing, let it be this: a Pod is disposable.

Kubernetes assumes it can delete any Pod at any time and start a new one somewhere else. Everything in this guide follows from that:

  • A controller, so a new Pod appears
  • A Service, so clients find the new Pod
  • Probes, so traffic waits until it is ready
  • A clean shutdown, so the old Pod finishes its work
  • Data on a PersistentVolume, so it survives the swap

You can set all of this up yourself with the YAML and the checklist above.

If you would like a second pair of eyes on your cluster, get a free DevOps assessment. Next reads: Kubernetes Deployment, Kubernetes Service and Kubernetes Namespace.