Reputation: 3680
I am aware about the hierarchical order of k8s resources. In brief,
The thing i want to empasise in this question is, why we have replicaset
. Why don't the deployment
directly handle or take responsibility of keeping the required number of pods running. But deployment
in turn relies on replicset
for this.
If k8s is designed this way there should be definitely some benefit of having replicaset
. And this is what i want to explore/understand in depth.
Upvotes: 6
Views: 1166
Reputation: 144
Both essentially serves the same purpose. Deployments are a higher abstraction and as the name suggests it deals with creating, maintining and upgrading the deployment (collection of pods) as a whole. Whereas, ReplicationControllers or Replica sets primary responsibility is to maintain a set of identical replicas (which you can achieve declaratively using deployments too, but internally it creates a resplicaset to enable this).
More specifically, when you are trying to perform a "rolling" update to your deployment, such as updating the image versions, the deployment internally creates a new replica set and performs the rollout. during the rollout you can see two replicasets for the same deployment. So in other words, Deployment needs the lower level "encapsulation" of Replica sets to achive this.
Upvotes: 6