Create a pod with specified name using kubectl in command line?

12/7/2019

Using kubectl command line, is it possible to define the exact pod name?

I have tried with

kubectl run $pod-name --image imageX

However, the resulted pod name is something like $pod-name-xx-yyy-nnn. So without using a yaml file, can I define the pod name using kubectl CLI?

-- sqr
kubectl
kubernetes
kubernetes-pod

1 Answer

12/7/2019

kubectl run creates a Deployment by default. A Deployment starts a ReplicaSet that manages the pods/replicas... and therefore has a generated pod name.

Run pod

To run a single pod you can add --restart=Never to the kubectl run command.

kubectl run mypod --restart=Never --image=imageX
-- Jonas
Source: StackOverflow