<p>Google course on Kubernetes proposes:  </p>

<pre><code>$ kubectl run kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1 --port=8080  
  kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. 
  Use kubectl run --generator=run-pod/v1 or kubectl create instead.
</code></pre>

<p>Now I'm trying to use the new syntax:  </p>

<pre><code>$ kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1  
$ kubectl expose deployment/kubernetes-bootcamp --port=8080 type=NodePort
</code></pre>

<p>I'm sure that they are not the same. Could anyone help me?</p>

<p>Rr</p>

<p>Not duplicate: I'm asking about equivalence of two commands</p>

<p>You can see what these commands do by executing a dry-run and inspecting the generated manifests:</p>

<pre><code>kubectl run kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1 --port=8080 \
  --dry-run -o yaml &gt; kubectl-run.yaml
</code></pre>

<p>And</p>

<pre><code>kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1 \
  --dry-run -o yaml &gt;kubectl-create.yaml
</code></pre>

<p>The only substantial difference between the two manifests is that there is no <code>ports</code> field in <code>kubectl-create.yaml</code>.</p>

<p>The <code>kubectl create deployment</code> command has no option for specifying any exposed ports of the container, so there's  probably no easy way to achieve exactly the same output as <code>kubectl run</code> with a <code>kubectl create</code> command.</p>

<p>The <code>kubectl expose</code> command that you're using just creates a Service resource and doesn't modify the Deployment resource.</p>

<p>In general, <code>kubectl create &lt;resource&gt;</code> commands are rather limited. They're mostly useful to either create a resource with only default settings, or to create the base for a manifest with <code>--dry-run -o yaml</code> that you can then customise.</p>
