Pod

A Pod is the smallest and simplest deployable unit in Kubernetes. It represents one or more containers that share the same network, storage, and lifecycle.

Let’s break it down clearly πŸ‘‡


🧩 What Is a Pod?

  • A Pod is a wrapper around one or more containers (usually Docker containers).
  • Containers in a Pod:
    • Share the same network namespace (same IP address and ports).
    • Can communicate via localhost.
    • Can share volumes for persistent or shared storage.
  • Kubernetes always schedules Pods, not containers directly.

πŸ“¦ Pod Structure

A Pod can contain:

  1. Application containers – the main app or service.
  2. Sidecar containers – supporting tasks (e.g., logging, monitoring, proxying).

Example:

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
spec:
  containers:
    - name: main-app
      image: nginx
      ports:
        - containerPort: 80
    - name: log-agent
      image: busybox
      command: ["sh", "-c", "tail -f /var/log/nginx/access.log"]

Here:

  • main-app runs Nginx.
  • log-agent collects logs from the same Pod.

🌐 Networking

  • Each Pod gets its own IP address within the cluster.
  • Containers in the same Pod share that IP.
  • Different Pods communicate via Services (not directly).

πŸ’Ύ Storage

  • Pods can use Volumes to store and share data between containers.
  • Volumes persist as long as the Pod exists (but not beyond its lifecycle).

πŸ”„ Lifecycle

  • Pods are ephemeral β€” if a Pod dies, it’s not β€œrestarted”; instead, a new Pod is created by a higher-level controller like a Deployment or ReplicaSet.
  • Typical Pod phases:
    • Pending
    • Running
    • Succeeded
    • Failed
    • Unknown

βš™οΈ Controllers That Manage Pods

Pods are rarely created directly β€” they’re usually managed by controllers:

  • Deployment β€” for stateless apps.
  • StatefulSet β€” for stateful apps.
  • DaemonSet β€” for per-node Pods (like agents).
  • Job / CronJob β€” for batch or scheduled tasks.

🧠 Key Points to Remember

  • Pods are atomic units of deployment in Kubernetes.
  • Containers inside a Pod are tightly coupled and should be designed to work together.
  • When you scale an app, you scale Pods, not individual containers.
  • Pods are transient; use Persistent Volumes for long-term data.

Leave a Reply