DCA · Question #102
Does this command display all the pods in the cluster that are labeled as 'env: development'? Solution: 'kubectl get pods --all-namespaces -I env=development'
The correct answer is A. Yes. This command correctly uses the short form of the label selector flag (-l) to filter pods by the specified label across all namespaces.
Question
Does this command display all the pods in the cluster that are labeled as 'env: development'? Solution: 'kubectl get pods --all-namespaces -I env=development'
Options
- AYes
- BNo
How the community answered
(67 responses)- A93% (62)
- B7% (5)
Why each option
This command correctly uses the short form of the label selector flag (`-l`) to filter pods by the specified label across all namespaces.
Yes. The `kubectl get pods` command with the `-l` (or `--selector`) flag is the correct way to filter Kubernetes resources by label, and `--all-namespaces` ensures it searches across the entire cluster. Therefore, this command will display all pods labeled 'env: development' from all namespaces.
The `-l` flag is the correct and standard way to specify a label selector for filtering resources in `kubectl get` commands.
Concept tested: Kubernetes label selection
Source: https://kubernetes.io/docs/reference/kubectl/cheatsheet/#listing-getting-resources
Topics
Community Discussion
No community discussion yet for this question.