ReplicaSet
A ReplicaSet ensures a specified number of identical pod replicas run at all times, recreating failed pods; it is typically managed by a Deployment.
A ReplicaSet is a Kubernetes controller whose single job is to maintain a stable set of replica pods running at any given time. If pods are deleted, crash, or a node fails, the ReplicaSet creates replacements to restore the desired count; if there are too many, it removes the extras.
How It Works
A ReplicaSet has three key parts: a replica count, a pod template describing the pods to create, and a label selector that identifies which pods it owns. The controller continuously compares the number of matching pods against the desired count and reconciles any difference.
In practice, you rarely create a ReplicaSet directly. A Deployment creates and manages ReplicaSets on your behalf, using a new ReplicaSet per revision to perform rolling updates and rollbacks. The Deployment adds version history and update strategy on top of the ReplicaSet's basic replica-keeping behavior.
Why It Matters
The ReplicaSet provides the self-healing and horizontal-scaling foundation of Kubernetes for stateless workloads. By guaranteeing a target number of interchangeable pods, it makes applications resilient to individual pod and node failures without manual intervention.
Understanding ReplicaSets clarifies what happens beneath a Deployment, which helps when debugging rollouts, orphaned pods, or selector conflicts. Because a Horizontal Pod Autoscaler adjusts replica counts, it works through the controller managing the ReplicaSet.
Related Terms
A ReplicaSet keeps pods running, is usually created by a Deployment, can be scaled by a Horizontal Pod Autoscaler, and is driven by the cluster control plane.