DEV Community

Cover image for Pods: The Heart of Kubernetes
Ibrahim S
Ibrahim S

Posted on

Pods: The Heart of Kubernetes

  • A pod is the smallest deployable object in the Kubernetes object model. A Pod:
  • Wraps one or more tightly coupled containers (usually one main container, possibly some sidecars).
  • Has a shared network namespace (shared IP address/port space among containers in the pod).
  • Shares storage volumes, if any are defined.
  • Because Pods are considered ephemeral in Kubernetes, they can be created, terminated, and re-created as the cluster responds to changing conditions—such as node failures, resource constraints, rolling updates, etc.

Pod phases are high-level summaries of the pod’s overall status. They give a quick idea of what is happening to the pod, but they are not a detailed or granular representation of container-level statuses. The primary pod phases are:

  1. Pending
  2. Running
  3. Succeeded
  4. Failed
  5. Unknown

Container States Within a Pod

Within a pod, each container has more detailed states than the overall pod phase. These are:

  1. Waiting
  2. Running
  3. Terminated

Common container waiting for reasons:

ContainerCreating: Kubernetes is pulling the container image or setting up the container.

CrashLoopBackOff: The container keeps failing (crashing) soon after starting, causing repeated restarts.

ImagePullBackOff: Kubernetes is unable to pull the container image, perhaps due to authentication issues or a wrong image path.

Each pod has conditions that provide more specific information. You can see pod conditions using kubectl describe pod. Common conditions include:

  1. PodScheduled
  2. Initialized
  3. Ready
  4. ContainersReady

Kubernetes provides lifecycle hooks that let you manage and inject custom behavior when containers start or before they terminate:

PostStart Hook

Triggered immediately after a container is created and started (but there’s no guarantee this hook will run before the container’s main process).

Useful for initialization tasks that need to run inside the container once it’s up.

Lifecycle Hooks (PostStart and PreStop) allow you to run custom logic at critical moments of container execution.

PreStop Hook

Triggered before the container is terminated.

Used for graceful shutdown tasks, like flushing buffers, notifying external systems, or cleaning up resources.

These hooks allow you to control the logic that is needed to run at critical points in the container’s lifecycle without altering the main application code.

  • Liveness probes let Kubernetes know if your application is alive or stuck in a deadlock.
  • Readiness probes signal when your pod is ready to serve traffic (affects service load balancing).
  • Startup probes help ensure slow-starting apps have enough time before Kubernetes marks them as unhealthy.

More about Pods: The Heart of Kubernetes

Top comments (0)