πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Configuration beginner ⏱ 15 minutes K8s 1.28+

Kubernetes Pod Lifecycle and States Explained

Understand the Kubernetes pod lifecycle from Pending to Terminated. Covers pod phases, container states, restart policies, graceful shutdown, and preStop hooks.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: Understand the Kubernetes pod lifecycle from Pending to Terminated. Covers pod phases, container states, restart policies, graceful shutdown, and preStop hooks.

The Problem

This is one of the most searched Kubernetes topics. Having a comprehensive, well-structured guide helps both beginners and experienced users quickly find what they need.

The Solution

Pod Phases

PhaseDescription
PendingPod accepted, waiting for scheduling or image pull
RunningAt least one container is running
SucceededAll containers exited with code 0
FailedAll containers terminated, at least one with non-zero exit
UnknownNode communication lost

Container States

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

# States: Waiting, Running, Terminated
# Waiting reasons: ContainerCreating, CrashLoopBackOff, ImagePullBackOff, PodInitializing
# Terminated reasons: Completed, Error, OOMKilled

Graceful Shutdown

apiVersion: v1
kind: Pod
spec:
  terminationGracePeriodSeconds: 60    # Default: 30
  containers:
    - name: app
      image: my-app:v1
      lifecycle:
        preStop:
          exec:
            command: ["/bin/sh", "-c", "sleep 5 && /app/shutdown.sh"]
        # preStop runs BEFORE SIGTERM is sent

Shutdown sequence:

  1. Pod marked for deletion
  2. Removed from Service endpoints (no new traffic)
  3. preStop hook runs
  4. SIGTERM sent to container
  5. Wait terminationGracePeriodSeconds
  6. SIGKILL if still running

Restart Policies

PolicyBehaviorUse Case
AlwaysRestart on any exit (default)Deployments, StatefulSets
OnFailureRestart only on non-zero exitJobs
NeverNever restartJobs (debug with logs)

Init β†’ Sidecar β†’ Main Container Ordering

graph LR
    A[Pod Created] --> B[Init Container 1]
    B --> C[Init Container 2]
    C --> D[Sidecar starts]
    D --> E[Main Container starts]
    E --> F[Running]
    F -->|Termination| G[preStop hook]
    G --> H[SIGTERM]
    H --> I[Grace period]
    I --> J[SIGKILL if needed]

Frequently Asked Questions

Why is my pod stuck in Pending?

Common reasons: insufficient CPU/memory on nodes, no nodes match nodeSelector/affinity, PVC not bound, taints without tolerations. Run kubectl describe pod and check the Events section.

What is the difference between pod phase and container state?

Pod phase is the overall pod status. Container state is per-container. A pod can be Running while one container is in CrashLoopBackOff (if there are other running containers).

Best Practices

  • Start simple β€” use the basic form first, add complexity as needed
  • Be consistent β€” follow naming conventions across your cluster
  • Document your choices β€” add annotations explaining why, not just what
  • Monitor and iterate β€” review configurations regularly

Key Takeaways

  • This is fundamental Kubernetes knowledge every engineer needs
  • Start with the simplest approach that solves your problem
  • Use kubectl explain and kubectl describe when unsure
  • Practice in a test cluster before applying to production
#pod-lifecycle #phases #graceful-shutdown #prestop #kubernetes
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens