ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 59 - DCA discussion

Report
Export

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'

A.

Yes

Answers
A.

Yes

B.

No

Answers
B.

No

Suggested answer: B

Explanation:

The command 'kubectl get pods --all-namespaces -I env=development' does not display all the pods in the cluster that are labeled as 'env: development'. The reason is that the flag -I is not a valid option for kubectl get pods.The correct flag to use is --selector or -l, which allows you to filter pods by labels1.Labels are key-value pairs that can be attached to Kubernetes objects to identify, group, or select them2. For example, to label a pod with env=development, one can run:

kubectl label pods my-pod env=development

To display all the pods that have the label env=development, one can run:

kubectl get pods --selector env=development

or

kubectl get pods -l env=development

The --all-namespaces flag can be used to list pods across all namespaces3. Therefore, the correct command to display all the pods in the cluster that are labeled as 'env: development' is:

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

or

kubectl get pods --all-namespaces -l env=developmentReference:

kubectl Cheat Sheet | Kubernetes

Labels and Selectors | Kubernetes

kubectl get | Kubernetes

asked 08/11/2024
Rosalba Scalera
48 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first