title: Add some labels to a deployment?
body: <p>I'm very beginner with K8S and I've a question about the labels with kubernetes. On youtube video (<a href="https://www.youtube.com/watch?v=JIaY9AXq_zM&amp;list=PLn6POgpklwWqfzaosSgX2XEKpse5VY2v5&amp;index=16" rel="nofollow noreferrer">In french here)</a>, I've seen that :</p>
  <p>The man create three deploys with these commands and run the command <code>kubectl get deployment</code> then <code>kubectl get deployment --show-labels</code> :</p>
  <pre><code>kubectl run monnginx --image nginx --labels &quot;env=prod,group=front&quot;
  kubectl run monnginx2 --image nginx --labels &quot;env=dev,group=front&quot;
  kubectl run monnginx3 --image nginx --labels &quot;env=prod,group=back&quot;
  </code></pre>
  <pre><code>root@kubmaster:# kubectl get deployments
  NAME            READY        UP-TO-DATE AVAILABLE      AGE
  monnginx         1/1             1          1          46s
  monnginx2        1/1             1          1          22s
  monnginx3        1/1             1          1          10s
        
  </code></pre>
  <pre><code>root@kubmaster:# kubectl get deployments --show-labels
  NAME            READY        UP-TO-DATE AVAILABLE      AGE   LABELS
  monnginx         1/1             1          1          46s   env=prod,group=front
  monnginx2        1/1             1          1          22s   env=dev,group=front 
  monnginx3        1/1             1          1          10s   env=prod,group=back
        
  </code></pre>
  <p>Currently, if I try to do the same things :</p>
  <pre><code>root@kubermaster:~ kubectl run mynginx --image nginx --labels &quot;env=prod,group=front&quot;
  pod/mynginx created
  
  root@kubermaster:~ kubectl run mynginx2 --image nginx --labels &quot;env=dev,group=front&quot;
  pod/mynginx2 created
  
  root@kubermaster:~ kubectl run mynginx3 --image nginx --labels &quot;env=dev,group=back&quot;
  pod/mynginx3 created
  
  </code></pre>
  <p>When I try the command <code>kubectl get deployments --show-labels</code>, the output is :</p>
  <pre><code>No resources found in default namespace.
  </code></pre>
  <p>But if I try <code>kubectl get pods --show-labels</code>, the output is :</p>
  <pre><code>NAME       READY   STATUS    RESTARTS   AGE     LABELS
  mynginx    1/1     Running   0          2m39s   env=prod,group=front
  mynginx2   1/1     Running   0          2m32s   env=dev,group=front
  mynginx3   1/1     Running   0          2m25s   env=dev,group=back
  </code></pre>
  <p>If I follow every steps from the videos, there is a way to put some labels on deployments... But the command <code>kubectl create deployment</code> does not accept the flag --labels :</p>
  <pre><code>Error: unknown flag: --labels
  </code></pre>
  <p>There is someone to explain why I've this error and How put some label ?</p>
  <p>Thanks a lot !</p>