<p>I am aware about the hierarchical order of k8s resources. In brief,</p>
<ol>
<li><strong>service:</strong> a service is what exposes the application to outer world (or with in cluster). (The <strong>service</strong> <strong>types</strong> like, CluserIp, NodePort, Ingress are not so much relevant to this question. )</li>
<li><strong>deployment:</strong> a deployment is what is responsible to keep a set of pods running.</li>
<li><strong>replicaset:</strong> a replica set is what a deployment in turn relies on to keep the set of pods running.</li>
<li><strong>pod:</strong> - a pod consist of a container or a group of container</li>
<li><strong>container</strong> - the actual required application is run inside the container.</li>
</ol>
<p>The thing i want to empasise in this question is, why we have <code>replicaset</code>. Why don't the <code>deployment</code> directly handle or take responsibility of keeping the required number of pods running. But <code>deployment</code> in turn relies on <code>replicset</code> for this.</p>
<p>If k8s is designed this way there should be definitely some benefit of having <code>replicaset</code>. And this is what i want to explore/understand in depth.</p>

samshers
<p>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).</p>
<p>More specifically, when you are trying to perform a &quot;rolling&quot; 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 &quot;encapsulation&quot; of Replica sets to achive this.
<a href="https://i.stack.imgur.com/C9U23.png" rel="noreferrer"><img src="https://i.stack.imgur.com/C9U23.png" alt="enter image description here" /></a></p>
