How do you create pod pod1 of image nginx in namespace ns1 that will have the container name c1?
Experience Level: Medior
Tags: Kubernetes
Answer
Run the following command to generate pod manifest:
kubectl run pod1 --image=nginx --dry-run=client -o yaml > pod.yaml
Then run the following to edit the file:
nano pod.yaml
Add namespace to metadata section, find the container name pod1 under containers section and change it to c1:
Then save the file and create the pod by running the following:
kubectl apply -f pod.yaml
Related Kubernetes job interview questions
You need to make sure that each pod scheduled as part of your Kubernetes job will have label myJobId="great job". How will you do that?
Kubernetes JuniorYou were asked to create a command that will display a status of a pod pod1 in namespace ns1. What will you do?
Kubernetes JuniorHow do you get a list of endpoints that are available for service service1?
Kubernetes MediorHow can you run a pod on each node of Kubernetes and make sure that it is running only once on on each node?
Kubernetes MediorHow do you find all pods that run on a master node?
Kubernetes Medior