Day 50: Pods, ReplicaSets, Deployments
The workload hierarchy
A Pod is the smallest deployable unit — one or more containers that always run together on the same node, sharing network and storage. You rarely create Pods directly; you create something that manages them.
A ReplicaSet ensures a specified number of identical Pod replicas are running at all times — its reconcile loop creates/deletes Pods to match the desired count. A Deployment manages ReplicaSets on your behalf, adding rolling updates and rollback: when you change a Deployment's Pod template (a new image version), it creates a new ReplicaSet and gradually shifts traffic from the old one to the new one.
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
replicas: 3
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: myapi:1.2.0kubectl set image deployment/api api=myapi:1.3.0
kubectl rollout status deployment/api
kubectl get replicasets # you'll briefly see both the old and new ReplicaSetKey terms
- Pod
- The smallest deployable unit — one or more co-located, co-scheduled containers.
- ReplicaSet
- Ensures a specified number of identical Pod replicas are running.
- Deployment
- Manages ReplicaSets to provide declarative rolling updates and rollback.
When you update a Deployment's container image, what actually happens under the hood?