<p>At page 67 of <a href="https://www.oreilly.com/library/view/kubernetes-up-and/9781492046523/" rel="nofollow noreferrer">Kubernetes: Up and Running, 2nd Edition</a>, the author uses the command below in order to create a <code>Deployment</code>:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl run alpaca-prod \
--image=gcr.io/kuar-demo/kuard-amd64:blue \
--replicas=2 \
--labels=&quot;ver=1,app=alpaca,env=prod&quot;
</code></pre>
<p>However this command is deprecated with kubectl 1.19+, and it now creates a pod:</p>
<pre class="lang-sh prettyprint-override"><code>$ kubectl run alpaca-prod \     
--image=gcr.io/kuar-demo/kuard-amd64:blue \
--replicas=2 \
--labels=&quot;ver=1,app=alpaca,env=prod&quot;
Flag --replicas has been deprecated, has no effect and will be removed in the future.
pod/alpaca-prod created

$ kubectl version
Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;19&quot;, GitVersion:&quot;v1.19.0&quot;, GitCommit:&quot;e19964183377d0ec2052d1f1fa930c4d7575bd50&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2020-08-26T14:30:33Z&quot;, GoVersion:&quot;go1.15&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
Server Version: version.Info{Major:&quot;1&quot;, Minor:&quot;20&quot;, GitVersion:&quot;v1.20.2&quot;, GitCommit:&quot;faecb196815e248d3ecfb03c680a4507229c2a56&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-01-21T01:11:42Z&quot;, GoVersion:&quot;go1.15.5&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}

</code></pre>
<p>Is there a way to use <code>kubectl run</code> to create a deployment with replicas and custom label with <code>kubectl</code> 1.19+?</p>

Fabrice Jammes
<p>It is now preferred to use <code>kubectl create</code> to create a new <code>Deployment</code>, instead of <code>kubectl run</code>.</p>
<p>This is the corresponsing command to your <code>kubectl run</code></p>
<pre><code>kubectl create deployment alpaca-prod --image=gcr.io/kuar-demo/kuard-amd64:blue --replicas=2
</code></pre>
<h3>Labels</h3>
<p>By default from <code>kubectl create deployment alpaca-proc</code> you will get the label <code>app=alpaca</code>.</p>
<p>The get the other labels, you need to add them later. Use <code>kubectl label</code> to add labels to the <code>Deployment</code>, e.g.</p>
<pre><code>kubectl label deployment alpaca-prod ver=1
</code></pre>
<p><strong>Note:</strong> this only adds the label to the <code>Deployment</code> and <strong>not</strong> to the Pod-template, e.g. the Pods will not get the label. To also add the label to the pods, you need to edit the <code>template:</code> part of the Deployment-yaml.</p>
