<p>I have created a pod using below yaml:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
    name: pod2
    labels:
       app: dc1
spec:
    containers:
      - name: cont1
        image: nginx
</code></pre>
<p>Now, I am creating a <code>deployment controller</code> with the selector value as <code>app=dc1</code> using the below command:
<br>
<code>kubectl create deploy dc1 --image=nginx</code></p>
<p>Note: When we create a deployment with the name &quot;dc1&quot;, it automatically creates selector <code>app=dc1</code> for the deployment controller.</p>
<p><br><br></p>
<p>I notice that the deployment controller <code>creates a new pod</code> instead of selecting the already existing pod.</p>
<pre><code>NAME                READY   STATUS    RESTARTS   AGE   LABELS
dc1-969ff47-ljbxk   1/1     Running   0          32m   app=dc1,pod-template-hash=969ff47
pod1                1/1     Running   0          33m   app=dc1
</code></pre>
<br>
<p><strong>Question:</strong> <br>
Why <code>dc1</code> is not selecting the existing <code>pod1</code> which has the same label <code>app=dc1?</code></p>
<p><br><br></p>

meallhour
<p><code>Why dc1 is not selecting the existing pod1 which has the same label app=dc1?</code></p>
<p>Because pod1 was not originated by a deployment which spawn a replicaset that would add <code>pod-template-hash</code> to the pod labels (which your standalone pod will not have). In your case of replicaset, you didn't have <code>pod-template-hash</code> as part of its <code>selector.matchLabels</code>. If you do add one, the replicaset will not select your standalone pod.</p>
