The extra ReplicaSet layer is what makes rolling updates and instant rollbacks possible.
You edit the Deployment. It creates a new ReplicaSet for each pod-template change and keeps old ones around, scaled to zero.
Deployment checkout
replicas: 3, image checkout:1.4
ReplicaSet -7d9f8
image 1.4, scaled to 3
podpodpod
ReplicaSet -5c4b1
image 1.3, scaled to 0 (kept for rollback)
---
rollback is just flipping scale
$ kubectl get rs -l app=checkout NAME DESIRED CURRENT READY checkout-7d9f8 3 3 3 checkout-5c4b1 0 0 0 $ kubectl rollout undo deployment/checkout $ kubectl rollout history deployment/checkout
History limit
revisionHistoryLimit (default 10) controls how many old ReplicaSets are kept.
Pod template hash
The suffix in a ReplicaSet name is a hash of the pod template, so any template change makes a new one.