CKAD — Pod Lifecycle

3 minute read

Pod Lifecycle Overview

Understanding the Pod lifecycle helps you debug issues and design resilient applications. Every Pod goes through a series of phases from creation to termination.

Pending → Running → Succeeded/Failed
              ↓
          Terminating

Pod Phases

Phase Description
Pending Pod accepted but containers not yet running. Could be waiting for scheduling, image pull, or volume mount.
Running At least one container is running.
Succeeded All containers exited with code 0. Common for Jobs.
Failed At least one container exited with a non-zero code.
Unknown Pod state cannot be determined. Usually a node communication issue.

Container States

Each container within a Pod has its own state, independent of the Pod phase:

State Description
Waiting Container is not running yet. Reasons include ContainerCreating, CrashLoopBackOff, ImagePullBackOff.
Running Container is executing.
Terminated Container finished running — either successfully (exit code 0) or with an error.

Container Restart Policy and CrashLoopBackOff

When a container crashes, Kubernetes restarts it with an exponential backoff delay:

Crash → 10s → 20s → 40s → 80s → 160s → 300s (capped at 5 min)

This is the infamous CrashLoopBackOff state. The container keeps crashing and Kubernetes keeps trying to restart it with increasing delays.

Common causes of CrashLoopBackOff:

Cause How to Debug
Application error kubectl logs <pod>
Missing config/secrets kubectl describe pod <pod> → check Events
Wrong command/args Check command and args in Pod spec
Permission issues Check SecurityContext, file permissions
Port conflicts Check if another container uses the same port

Checking Pod Status

# Quick status check
kubectl get pod web

# Detailed status including conditions and events
kubectl describe pod web

# Check container state directly
kubectl get pod web -o jsonpath='{.status.containerStatuses[0].state}'

# Watch for status changes
kubectl get pod web -w

# Get the Pod phase
kubectl get pod web -o jsonpath='{.status.phase}'

# Get container restart count
kubectl get pod web -o jsonpath='{.status.containerStatuses[0].restartCount}'

Pod Conditions

Pod conditions provide additional detail beyond the phase:

Condition Description
PodScheduled Pod has been scheduled to a node
Initialized All init containers have completed
ContainersReady All containers in the Pod are ready
Ready Pod is ready to serve requests (passes readiness checks)
# Check Pod conditions
kubectl get pod web -o jsonpath='{.status.conditions[*].type}'

# Check if Pod is ready
kubectl get pod web -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'

Common Pending Reasons

Reason Cause Fix
ImagePullBackOff Image not found or no access Check image name, tag, and pull secrets
Pending (no events) No node has enough resources Check node resources or adjust requests
ContainerCreating Volume mounting or image pulling Wait or check PVC/image availability
CrashLoopBackOff Container keeps crashing Check logs with kubectl logs
ErrImagePull Registry authentication failure Create or fix imagePullSecrets
FailedScheduling No nodes match constraints Check nodeSelector, affinity, taints/tolerations

Debugging a Failing Pod — Step by Step

When a Pod is not running correctly, follow this debugging workflow:

# Step 1: Check Pod status
kubectl get pod <name>

# Step 2: Read the events
kubectl describe pod <name>

# Step 3: Check container logs
kubectl logs <name>
kubectl logs <name> --previous    # logs from the last crash

# Step 4: Check resource constraints
kubectl describe node <node-name> | grep -A 5 "Allocated resources"

# Step 5: Exec into the container (if running)
kubectl exec -it <name> -- /bin/sh

Pod Termination Lifecycle

When you delete a Pod, Kubernetes follows a graceful shutdown process:

  1. Pod status set to Terminating
  2. Pod removed from Service endpoints (stops receiving traffic)
  3. preStop hook runs (if configured)
  4. SIGTERM sent to container processes
  5. Grace period countdown starts (default: 30 seconds)
  6. If still running after grace period, SIGKILL is sent
  7. Pod removed from the API server
# Delete with default grace period (30s)
kubectl delete pod web

# Delete with custom grace period
kubectl delete pod web --grace-period=60

# Force delete immediately
kubectl delete pod web --grace-period=0 --force

Exam tip: Understanding Pod lifecycle is critical for debugging questions. The CKAD exam will give you Pods in bad states and ask you to fix them. Practice the describe → logs → exec debugging flow until it is muscle memory.


Next: Learn about temporary storage with Ephemeral Volumes →

Updated: