<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>

<p>The flags are intentionally meant to create different kind of objects. I am copying from the help of <code>kubectl run</code>:</p>

<pre><code>  --restart='Always': The restart policy for this Pod.  Legal values [Always, 
OnFailure, Never].  If set to 'Always' a deployment is created, if set to 
'OnFailure' a job is created, if set to 'Never', a regular pod is created. For 
the latter two --replicas must be 1.  Default 'Always', for CronJobs `Never`.
</code></pre>

<ul>
<li><code>Never</code> acts like a cronjob which is scheduled immediately. </li>
<li><code>Always</code> creates a deployment and the deployment monitors the pod and restarts in case of failure.</li>
</ul>
