Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
K8s Basics Kubernetes Kubernetes: From Zero to Production Module 3 - Pods and Workloads pods

What Is a Pod? The Smallest K8s Unit

Reviewed & accurate
AI Summary

What You Will Learn

Beginner

  • What a Pod is and why it exists
  • How to create a Pod
  • Pod lifecycle and states

A Pod is the smallest deployable unit in Kubernetes. It contains one or more containers that share networking and storage. Usually, one container per Pod.

Why Pods, not containers?
Kubernetes could manage containers directly, but Pods add shared networking (same IP, ports) and shared volumes for tightly-coupled containers. 99% of Pods have exactly 1 container.
pod.yamlyaml
apiVersion: v1
kind: Pod
metadata:
  name: my-web
  labels:
    app: web
spec:
  containers:
  - name: nginx
    image: nginx:alpine
    ports:
    - containerPort: 80
    resources:
      limits:
        memory: "128Mi"
        cpu: "250m"
Terminalbash
# Create the Pod
kubectl apply -f pod.yaml

# Check it
kubectl get pods
kubectl describe pod my-web

# Access it
kubectl port-forward my-web 8080:80
# Open http://localhost:8080

# Delete
kubectl delete pod my-web

Pod States

StateMeaning
PendingCreated but not yet running (pulling image, scheduling)
RunningContainer is executing
SucceededCompleted successfully (batch jobs)
FailedContainer exited with error
CrashLoopBackOffCrashing repeatedly - check logs!

Practical Exercise

Create pod.yaml with nginx:alpine
Apply: kubectl apply -f pod.yaml
Check: kubectl get pods - wait for Running
Port-forward: kubectl port-forward my-web 8080:80
Open browser: http://localhost:8080
Clean up: kubectl delete pod my-web

Key Takeaways

  • Pod = smallest K8s unit. Usually 1 container per Pod.
  • Containers in a Pod share networking (same IP) and volumes.
  • Create: kubectl apply -f pod.yaml.
  • States: Pending, Running, Succeeded, Failed, CrashLoopBackOff.
  • Port-forward: kubectl port-forward to access locally.
Previously: Module 2 covered cluster architecture.
Today: You learned: The smallest deployable unit in Kubernetes.
Next: Lesson 13 covers multi-container Pods.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments