<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>If you check your replica set after deploying the deployment. You will notice a new label by the name <em><strong>pod-template-hash</strong></em></p>
<pre><code>kubectl get replicasets  dc1-xxxxx  -o yaml
</code></pre>
<p>It is generated by hashing the PodTemplate</p>
<pre><code>labels:
    app: dc1
    pod-template-hash: xxxxxxxx
</code></pre>
<p>If you define both labels on your pod, your pod then will be managed by Deployments.</p>
<p>But this is not recommended by the <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#selector" rel="nofollow noreferrer">Kubernetes</a></p>
<blockquote>
<p>Note: You should not create other Pods whose labels match this selector, either directly, by creating another Deployment, or by creating another controller such as a ReplicaSet or a ReplicationController. If you do so, the first Deployment thinks that it created these other Pods. Kubernetes does not stop you from doing this.</p>
</blockquote>
