Why was ReplicaSet introduced in Kubernetes?
ReplicaSet
is usually not standalone, these are owned by Deployment
. A single Deployment
can have many ReplicaSet
s in its life cycle as new Version
deployment added one more ReplicaSet
.
Deployment
allows us to rollback to previous stable releases if required.
Replicasets is updated version of Replication controller
In Replication controller there equality-based selectors
In Replicasets there is set-based selectors
Replicasets also work with deployment so when you do simple deployment in kubernetes replicasets automatically generated and managed.so deployment owned
replicasets.
I think this can be summed up to the 3 points below.
1 ) ReplicaSet is a replacement for the Replica controller and supports richer expressions for the label selector. You can choose between four values of operators In, NotIn, Exists, DoesNotExist
- see Set-based requirement.
2 ) There is a small differnece in the syntax - ReplicaSet which contains matchLabels
field under the selector:
apiVersion: apps/v1kind: ReplicaSetmetadata: name: nginxspec: replicas: 3 selector: matchLabels: #<-- This was added tier: nginx
3 ) When you see Replica Controller is mentioned in one the docs or other tutorials - refer to it as ReplicaSet AND consider using Deployment instead.