Does this command display all the pods in the cluster that are labeled as ‘env: development’?
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
B . No
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=development
Reference: kubectl Cheat Sheet | Kubernetes
Labels and Selectors | Kubernetes
kubectl get | Kubernetes
Latest DCA Dumps Valid Version with 55 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund