ReplicaSets
ReplicaSets
A ReplicaSet keeps N copies of a Pod running. That is the whole job.
graph LR
RS[ReplicaSet replicas=3] --> P1[Pod]
RS --> P2[Pod]
RS --> P3[Pod]
P2 -.node dies.-> X((gone))
RS -->|reconcile| P4[new Pod]
The loop never stops: count Pods matching the selector, compare with
spec.replicas, create or delete the difference. Self-healing and scaling are
the same mechanism.
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web # must match the selector
Pods are bound by the selector, not by name: a loose Pod carrying a matching label gets adopted and counted.
A ReplicaSet has no rollout logic - changing the template does nothing to running Pods. That missing piece is exactly what a Deployment adds, which is why you never write ReplicaSets by hand. You read them when a rollout misbehaves.