<p>Can I know why kubectl run sometimes create deployment and sometimes pod. </p>

<p>You can see 1st one creates pod and 2nd one creates deployment. only diff is --restart=Never</p>

<pre><code>
// 1
chams@master:~/yml$ kubectl run ng --image=ngnix --command --restart=Never --dry-run -o yaml
apiVersion: v1
kind: Pod
..
status: {}

//2
chams@master:~/yml$ kubectl run ng --image=ngnix --command  --dry-run -o yaml
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.
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    run: ng
  name: ng
..
status: {}
</code></pre>

Chaminda
<p>By default <code>kubectl run</code> command creates a <strong>Deployment.</strong></p>

<p>Using <code>kubectl run</code> command you can create and run a particular image, possibly replicated.
Creates a deployment or job to manage the created containers.</p>

<p>The difference in your case is seen in command (1st one)  including restart policy argument.</p>

<p>If value of restart policy is set to '<strong>Never</strong>', a regular <strong>pod</strong> is created. For the latter two --replicas must be 1. Default '<strong>Always</strong>', for CronJobs Never.</p>

<p>Try to use command:</p>

<pre><code>$ kubectl run --generator=run-pod/v1 ng --image=ngnix --command  --dry-run -o yaml
</code></pre>

<p>instead of</p>

<pre><code>$ kubectl run ng --image=ngnix --command  --dry-run -o yaml
</code></pre>

<p>to avoid statement 
<code>"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></p>

<p>More information you can find here:<a href="https://kubernetes.io/docs/reference/kubectl/docker-cli-to-kubectl/" rel="nofollow noreferrer">docker-kubectl</a>, <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" rel="nofollow noreferrer">kubectl-run</a>.</p>
