You were asked to create a command that will display a status of a pod pod1 in namespace ns1. What will you do?
Experience Level: Junior
Tags: Kubernetes
Answer
Option 1:
Run the following command:
echo "kubectl describe pod busybox -n default|grep -i Status:" > get-status.sh
Option 2:
Run the following command:
echo "kubectl get pod busybox -n default --no-headers|awk '{print $3}'" > get-status.sh
Option 3:
Run the following command:
echo "kubectl get pod busybox -n default -o jsonpath='{.status.phase}'" > get-status.sh
To run the Shell file, run the following:
sh get-status.sh
Related Kubernetes job interview questions
How do you display a history of job executions in Kubernetes?
Kubernetes JuniorYou 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 JuniorHow do you create pod pod1 of image nginx in namespace ns1 that will have the container name c1?
Kubernetes MediorHow 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 Medior