In World 1 a ReplicaSet kept three Pods alive. In production you almost never create a ReplicaSet yourself. You create a , and it creates the ReplicaSets.
The chain
Deployment market-web spec.replicas: 3
│ spec.template: { image: nginx:1.27 }
└─▶ ReplicaSet market-web-7676f9f845 (revision 1, hash of the template)
├─▶ Pod market-web-7676f9f845-b96cw
├─▶ Pod market-web-7676f9f845-d4rj7
└─▶ Pod market-web-7676f9f845-kl4h4The suffix on the ReplicaSet is a hash of the Pod template. The Pods carry that hash plus a random suffix.
Two kinds of change
Scaling changes spec.replicas. The template is untouched, so the same ReplicaSet grows or shrinks.
kubectl scale deploy market-web --replicas=5
kubectl get rsOne ReplicaSet, DESIRED 5.
Rolling out changes spec.template (image, env, labels, resources). The template hash changes, so the Deployment creates a second ReplicaSet and moves Pods from the old one to the new one.
kubectl set image deploy/market-web nginx=nginx:1.26
kubectl get rsNAME DESIRED CURRENT READY AGE
market-web-7676f9f845 0 0 0 5m
market-web-5b8c9d7f4b 5 5 5 20sThe old ReplicaSet stays at 0. It is the rollback.
revisionHistoryLimit
revision 1 market-web-7676f9f845 0 replicas kept
revision 2 market-web-5b8c9d7f4b 5 replicas currentspec.revisionHistoryLimit (default 10) is how many zero-replica ReplicaSets are kept. Past that, the oldest are deleted and can no longer be rolled back to.
What to read
| Question | Command |
|---|---|
| How many Pods are wanted and ready | kubectl get deploy |
| Which revisions exist and how many Pods each owns | kubectl get rs |
| Which revision a Pod belongs to | the hash in its name, or kubectl describe pod → Controlled By |
Next: scale the Market up and down and count the ReplicaSets yourself.