Pods

💤0
Lv 10 XP
← 📦 Containers & Kubernetes · Kubernetes

Pods

Beginner ⭐ 50 XP ⏱ 16 min #kubernetes#pods

The smallest deployable unit in Kubernetes — what a Pod is and how to work with one.

📖Theory

A Pod is the smallest deployable unit — one or more containers that share a network namespace (same IP, can talk over localhost) and storage volumes, always scheduled together on one node.

You rarely create bare Pods directly; controllers like Deployments manage them so they’re recreated if they die. Multiple containers in a Pod are for tightly- coupled helpers — a sidecar (log shipper, proxy) — not separate applications.

Key Pod concepts: resource requests/limits (CPU/memory), probes (liveness/readiness), and restart policy. Pods are ephemeral — their IPs change, which is why Services exist.

🌍Real-World Example
apiVersion: v1
kind: Pod
metadata:
  name: web
spec:
  containers:
    - name: nginx
      image: nginx:1.27
      ports: [{ containerPort: 80 }]
      resources:
        requests: { cpu: "100m", memory: "128Mi" }
        limits:   { cpu: "500m", memory: "256Mi" }
      readinessProbe:
        httpGet: { path: /, port: 80 }
kubectl apply -f pod.yaml
kubectl get pods
kubectl describe pod web
kubectl logs web
✍️Hands-On Exercise
  1. Write a minimal Pod manifest running an nginx container.
  2. Add CPU/memory requests and limits and explain the difference.
  3. Add a readiness probe and describe what it controls.
  4. Explain why you’d use a Deployment rather than a bare Pod.
🧾Cheat Sheet
ConceptDetail
PodSmallest unit; 1+ containers
SharedNetwork (IP) + volumes
SidecarHelper container in a Pod
RequestsGuaranteed resources
LimitsMaximum resources
Liveness probeRestart if unhealthy
Readiness probeGate traffic
💬Common Interview Questions
What is a Pod?

The smallest deployable unit in Kubernetes — one or more containers sharing a network namespace (one IP) and storage, scheduled together on one node.

What's the difference between a liveness and a readiness probe?

A liveness probe restarts a container that’s stuck; a readiness probe controls whether the Pod receives traffic, removing it from Service endpoints when not ready.

Why use multiple containers in one Pod?

For tightly-coupled helpers (sidecars) that must share the Pod’s network and storage — like a log forwarder or proxy — not for unrelated applications.

📚Official Documentation

📝 My notes on this topic

Auto-saves as you type