Kubernetes Series - Part 2: Container vs Pod vs Deployment Explained
In the previous article, we explored Kubernetes Architecture and how different components interact inside a cluster.
In this article, we'll dive into one of the most fundamental Kubernetes concepts:
Container → Pod → Deployment
Understanding these three concepts is critical because almost every Kubernetes workload is built on top of them.
Why Do We Need Container, Pod and Deployment?
A common misconception among beginners is:
"Aren't Container, Pod, and Deployment all used to run applications?"
The answer is Yes, but each solves a different problem.
| Resource | Responsibility |
|---|---|
| Container | Runs the application |
| Pod | Hosts and groups containers |
| Deployment | Manages and maintains Pods |
Think of it like:
Application
↓
Container
↓
Pod
↓
Deployment
Each layer adds new capabilities.
Step 1: Understanding Containers
A Container is the actual instance of your application.
For example:
docker run nginx
This launches an Nginx container.
A container includes:
- Application code
- Runtime environment
- Libraries
- Dependencies
- Configuration
Real-World Example
Imagine you have a Java application.
Java Application
│
▼
Docker Image
│
▼
Container
The container contains:
JDK
+
Application JAR
+
Required Libraries
Everything needed to run the application travels together.
This is why containers work consistently across:
- Local Laptop
- QA Environment
- Staging
- Production
Problem With Using Only Containers
Suppose your container crashes.
Container
↓
Crash
↓
Application Down
Questions arise:
- Who recreates the container?
- Who scales containers?
- Who updates them?
A standalone container cannot solve these problems.
This is where Kubernetes enters the picture.
Step 2: Understanding Pods
Kubernetes doesn't directly manage containers.
Instead, Kubernetes runs containers inside Pods.
What Is a Pod?
A Pod is the smallest deployable unit in Kubernetes.
A Pod can contain:
1 Container
or
Multiple Containers
Single Container Pod
Most common scenario:
Pod
│
└── Nginx Container
Multi-Container Pod
Pod
│
├── Application Container
│
└── Log Forwarder Container
Example:
Application Container
+
Fluent Bit Container
The Fluent Bit sidecar collects logs generated by the application.
Why Do Containers Need Pods?
Pods provide three important capabilities.
1. Shared Network
Every Pod gets a unique IP.
Example:
Pod IP = 10.244.1.5
All containers inside that Pod share the same IP.
Application Container
Logging Container
can communicate using:
localhost
2. Shared Storage
Containers inside the same Pod can access common storage.
volumeMounts:
Example:
Application writes logs
↓
Shared Volume
↓
Log Collector reads logs
3. Shared Lifecycle
Containers inside a Pod:
- Start together
- Stop together
- Get scheduled together
Kubernetes treats them as a single unit.
Life of a Pod
Let's say Kubernetes creates a Pod.
Pod Created
↓
Container Starts
↓
Application Running
Everything works fine.
Suddenly:
Node Failure
or
Application Crash
Result:
Pod Lost
Now what?
Problem With Pods
Pods are temporary.
They are designed to be:
Created
Destroyed
Recreated
A standalone Pod does not automatically recreate itself.
Example:
kubectl delete pod nginx
Result:
Pod Deleted
No automatic recovery.
Application becomes unavailable.
Step 3: Understanding Deployments
This is where Deployments become important.
What Is a Deployment?
A Deployment is a Kubernetes controller that manages Pods.
Instead of creating Pods directly:
kind: Pod
we create:
kind: Deployment
Deployment Architecture
Deployment
│
▼
ReplicaSet
│
▼
Pods
│
▼
Containers
Why Do We Need Deployments?
Deployments solve four major problems:
Self-Healing
Scaling
Rolling Updates
Rollbacks
1. Self-Healing
Deployment maintains a desired state.
Example:
replicas: 3
Desired state:
3 Pods Running
Current state:
Pod-1
Pod-2
Pod-3
Pod-2 crashes.
Pod-2 Down
Deployment detects:
Desired = 3
Actual = 2
Immediately creates:
New Pod-2
Final state:
Pod-1
Pod-2
Pod-3
This feature is called Self-Healing.
2. Scaling
Traffic increases.
100 Users
↓
10,000 Users
You need more application instances.
Update:
replicas: 10
or run:
kubectl scale deployment nginx --replicas=10
Deployment creates additional Pods automatically.
Pod-1
Pod-2
...
Pod-10
3. Rolling Updates
Current Application:
v1.0
New Release:
v2.0
Without Deployment:
Stop Everything
Deploy New Version
Start Everything
Downtime occurs.
With Deployment:
Create New Pod
↓
Verify Health
↓
Remove Old Pod
Repeat until every Pod is updated.
No Downtime
4. Rollback
New release causes issues.
v2.0
↓
Application Failure
Deployment allows rollback.
kubectl rollout undo deployment/nginx
Kubernetes restores the previous working version.
v1.0 Restored
The Complete Picture
Deployment
│
├── Maintains Desired State
├── Performs Scaling
├── Handles Updates
├── Provides Rollback
└── Creates Pods
│
▼
Pod
│
├── Shared Network
├── Shared Storage
└── Shared Lifecycle
│
▼
Container
│
└── Runs Application
Real Production Example
Consider an e-commerce application.
Container
Spring Boot Application
runs inside:
Container
Pod
Pod
├── Spring Boot Container
└── FluentBit Container
Both share:
- Storage
- Network
- Lifecycle
Deployment
replicas: 5
Ensures:
5 Healthy Pods
always remain available.
If one Pod crashes:
Automatically Recreated
If traffic spikes:
Scale to 10 Pods
If deployment fails:
Rollback
Interview Question
Why are Deployments preferred over Pods in production?
Answer:
Pods only run containers and provide a shared execution environment. They do not offer self-healing, scaling, rolling updates, or rollback capabilities. Deployments manage Pods and maintain the desired state of the application, making them the preferred choice for production workloads.
Quick Comparison
| Feature | Container | Pod | Deployment |
|---|---|---|---|
| Runs Application | ✅ | ✅ | Indirectly |
| Smallest Kubernetes Object | ❌ | ✅ | ❌ |
| Contains Multiple Containers | ❌ | ✅ | ❌ |
| Shared Network | ❌ | ✅ | ❌ |
| Shared Storage | ❌ | ✅ | ❌ |
| Self-Healing | ❌ | ❌ | ✅ |
| Scaling | ❌ | ❌ | ✅ |
| Rolling Update | ❌ | ❌ | ✅ |
| Rollback | ❌ | ❌ | ✅ |
| Production Ready | ❌ | Rarely | ✅ |
Key Takeaway
Remember this simple statement:
Containers run applications, Pods host containers, and Deployments manage Pods.
Or even simpler:
Container = Application
Pod = Home for Containers
Deployment = Pod Manager
Once you understand this hierarchy, concepts like Services, Ingress, HPA, StatefulSets, DaemonSets, and Argo CD become much easier to understand.
Top comments (0)