ReplicaSets are a k8s construct for maintaining a number of Pods replicas at all times. They are the successor of the ReplicationController construct and are a lower-level concept than a Deployment.
Note
It’s generally advised against using them directly.
They use label selectors1 to acquire pods for management and ownerReference fields 2 for garbage collection3 and to prevent other controllers from trying to manage its pods (dependants). Furthermore, they use pod templates4 to create new pods from.
Important
Unlike a Deployment, RSs don’t provide declarative updates to pods with revision control.
Warning
ReplicaSets can acquire pods with a different
.specas long as their labels match its selector. They don’t evaluate whether their template matches the “to-be-acquired” pod’s.spec.
Note
Pods with matching labels, but with an
ownerReferencethat is a controller5 will not be acquired by the ReplicaSet. If, however, the pod lacks an owner reference or the reference is not a controller, the RS with a matching selector will acquire the pod immediately.
Sources
Footnotes
-
See Pod Templates. ↩
-
See k8s controllers. ↩