Skip to main content
mid
intermediate
Kubernetes

Kubernetes Pod Lifecycle

Question

Explain the different phases of a Kubernetes Pod lifecycle and what happens during each phase.

Answer

A Kubernetes Pod goes through several phases: Pending (waiting for scheduling or image pulls), Running (at least one container is running), Succeeded (all containers terminated successfully), Failed (at least one container failed), and Unknown (Pod state cannot be determined). Each phase reflects the Pod's current status in the cluster.

Why This Matters

Understanding Pod lifecycle is crucial for debugging applications and implementing proper health checks. The lifecycle begins when a Pod is created and ends when it's deleted or evicted. During this time, Kubernetes continuously monitors and manages the Pod's state through its control loops.

Code Examples

Check Pod phase

bash

Pod with lifecycle hooks

yaml
Common Mistakes
  • Confusing Pod phase with container state - a Running Pod can have containers in different states
  • Not implementing graceful shutdown handlers, leading to data loss
  • Setting terminationGracePeriodSeconds too low for applications that need cleanup time
Follow-up Questions
Interviewers often ask these as follow-up questions
  • What is the difference between a Pod restart policy of Always, OnFailure, and Never?
  • How do liveness and readiness probes affect the Pod lifecycle?
  • What happens when a Pod's container exceeds its memory limit?
Tags
kubernetes
pods
containers
orchestration
lifecycle