How to start a pod in command line without deployment in kubernetes? How to start a pod in command line without deployment in kubernetes? kubernetes kubernetes

How to start a pod in command line without deployment in kubernetes?


kubectl run nginx --image=nginx --port=80 --restart=Never

--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 [...]

see official document https://kubernetes.io/docs/user-guide/kubectl-conventions/#generators


Now there are two ways one can create pod through command line.

kubectl run nginx --image=nginx --restart=Never

OR

kubectl run --generator=run-pod/v1 nginx1 --image=nginx

See official documentation.https://kubernetes.io/docs/reference/kubectl/conventions/#generators


Use generators for this, default kubectl run will create a deployment object. If you want to override this behavior use "run-pod/v1" generator.

kubectl run --generator=run-pod/v1 nginx1 --image=nginx

You may refer the link below for better understanding.

https://kubernetes.io/docs/reference/kubectl/conventions/#generators