Pods, ReplicaSets, and Deployments
In Kubernetes, you rarely deploy bare containers or run bare pods. Instead, workloads are built as nested layers of abstraction. At the center is the Pod—the smallest deployable unit. Managing groups of identical pods is the ReplicaSet. Managing the lifecycle, updates, and rollbacks of ReplicaSets is the Deployment.
Together, these three abstractions turn a volatile group of containers into an elastic, self-healing, and upgradable application.
Workload Hierarchy & Self-Healing: Deployment → ReplicaSet → Pods
The Pod: The Atomic Unit
A Pod encapsulates one or more containers that share:
- A single IP address and port space (network namespace)
- Shared storage volumes
- IPC (inter-process communication) namespaces
- Co-scheduling rules: containers in the same pod are always placed onto the exact same worker node.
apiVersion: v1
kind: Pod
metadata:
name: api-pod
labels:
app: api
spec:
containers:
- name: api-server
image: node:18-alpine
ports:
- containerPort: 3000
- name: log-sidecar
image: fluent/fluent-bit:latest
Why Not Run Naked Pods?
If a worker node crashes or runs out of memory, any naked pod running on that node dies with it. The Kubernetes control plane will not automatically reschedule or resurrect a standalone pod. To ensure fault tolerance, you need a controller.
ReplicaSets: Guaranteeing Numbers
A ReplicaSet exists for one single purpose: to maintain a stable set of replica Pods running at any given moment.
It continuously observes the cluster using label selectors:
- Are there fewer running pods than
spec.replicas? Spawn new ones. - Are there more running pods than
spec.replicas? Terminate excess ones. - Did a node die containing Pod-2? Spawn an identical replacement on another node.
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: api-replicaset
spec:
replicas: 3
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: api-server
image: myorg/api:v1
While ReplicaSets guarantee scale and self-healing, they lack built-in mechanisms to roll out new container versions smoothly without deleting the entire set at once. That is why Deployments were created.
Deployments: The King of Workload Management
A Deployment is a declarative supervisor sitting on top of ReplicaSets. When you create a Deployment, it creates a ReplicaSet behind the scenes. When you update your container image from v1 to v2:
- The Deployment creates a new ReplicaSet for
v2. - It scales up the new
v2ReplicaSet incrementally (e.g. 1 pod at a time). - It scales down the old
v1ReplicaSet incrementally. - If the new version crashes or health checks fail, you can instantly rollback (
kubectl rollout undo).
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-frontend
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:1.25
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
memory: 256Mi
The Hierarchy in Action
Think of this triad as a corporate chain of command:
- Deployment: The strategist deciding which version of software is active and how rollouts occur.
- ReplicaSet: The manager making sure the exact headcount is maintained day and night.
- Pod: The worker executing the actual code inside container sandboxes.
Whenever you want to run stateless services on Kubernetes—web APIs, workers, frontends, or background microservices—a Deployment is almost always the right abstraction to write.
Enjoyed this breakdown?
Get notified when new lessons go live.