<p>Ho do you set the following label in an already applied deployment?</p>

<pre><code>kubectl label deployments my-deployment-v1 app=my-deployment
</code></pre>

<p>Is setting:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: my-deployment-v1
  labels:
    app: my-deployment
</code></pre>

<p>And I need, the following for a service to find it:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: my-deployment-v1
spec:
  template:
    metadata:
      labels:
        app: my-deployment
</code></pre>

<p>You need to <a href="https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment" rel="nofollow noreferrer">patch</a> your resource like this:</p>

<pre><code>kubectl patch deployments/my-deployment-v1 \
-p '{"spec":{"template":{"metadata":{"labels":{"app":"my-deployment"}}}}}'
</code></pre>
