Does this command display all the pods in the cluster that are labeled as ‘env: development’?

Does this command display all the pods in the cluster that are labeled as ‘env: development’?

Solution: ‘kubectl get pods –all-namespaces -label env=development’
A . Yes
B . No

Answer: B

Explanation:

= The command kubectl get pods –all-namespaces -label env=development is not valid because it has a syntax error. The correct syntax for listing pods with a specific label is kubectl get pods –all-namespaces –selector label=value or kubectl get pods –all-namespaces -l label=value. The error in the command is:

The option flag for specifying the label selector is –selector or -l, not -label. For example, -label env=development should be –selector env=development or -l env=development.

The correct command for listing all the pods in the cluster that are labeled as env: development is:

kubectl get pods –all-namespaces –selector env=development

This command will display the name, status, restarts, and age of the pods that have the label env:

development in all namespaces.

Reference: : Labels | Kube by Example : kubectl Cheat Sheet | Kubernetes

Latest DCA Dumps Valid Version with 55 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments