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'
Correct 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.
References: : Labels | Kube by Example : kubectl Cheat Sheet | Kubernetes