DCA · Question #101
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'
The correct answer is B. No. The provided command uses an incorrect flag for label selection, thus it will not display pods with the specified label.
Question
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'
Options
- AYes
- BNo
How the community answered
(30 responses)- A7% (2)
- B93% (28)
Why each option
The provided command uses an incorrect flag for label selection, thus it will not display pods with the specified label.
The `-label` flag is not a valid or recognized option for filtering Kubernetes resources by label in `kubectl get` commands.
No. The `kubectl get pods` command requires the `-l` or `--selector` flag to filter resources based on labels, not `-label`. Without the correct flag, the command will not apply the label filter as intended.
Concept tested: Kubernetes label selection syntax
Source: https://kubernetes.io/docs/reference/kubectl/cheatsheet/#listing-getting-resources
Topics
Community Discussion
No community discussion yet for this question.