DCA · Question #100
Does this command display all the pods in the cluster that are labeled as 'env: development'? Solution: 'kubectl get pods -I env=development'
The correct answer is A. Yes. The provided kubectl command uses the correct syntax to filter and display pods based on a specific label.
Question
Does this command display all the pods in the cluster that are labeled as 'env: development'? Solution: 'kubectl get pods -I env=development'
Options
- AYes
- BNo
How the community answered
(36 responses)- A92% (33)
- B8% (3)
Why each option
The provided `kubectl` command uses the correct syntax to filter and display pods based on a specific label.
The `kubectl get pods` command retrieves pod information. The `-l` (or `--selector`) flag is used to filter resources by labels, so `-l env=development` correctly selects and displays only the pods that have the label `env` with the value `development`.
The `-l` flag in `kubectl get pods` is the standard and correct way to filter pods by their associated labels.
Concept tested: Kubectl label selection
Source: https://kubernetes.io/docs/reference/kubectl/cheatsheet/#viewing-finding-resources
Topics
Community Discussion
No community discussion yet for this question.