Reputation: 427
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?
Upvotes: 1
Views: 10912
Reputation: 458
The $pod-name is a variable with some value let's say "hello". So when you are running the kubectl run command it will create a deployment. The deployment will create a replicaset with name "hello-xxxx" and the replicaset will create pod with name "replicasetname-xxx". If you want to create a pod using kubectl run use the below command "kubectl run times --generator=run-pod/v1 hello --image=busybox".
It will create a pod with name hello. You are suppose to replace hello and image name. Otherwise you could use "kubectl create pod hello --image=busybox".
Upvotes: 0
Reputation: 129075
kubectl run
creates a Deployment by default. A Deployment starts a ReplicaSet that manages the pods/replicas... and therefore has a generated pod name.
To run a single pod you can add --restart=Never
to the kubectl run
command.
kubectl run mypod --restart=Never --image=imageX
Upvotes: 6