Bird
0
0

Given these pods with labels:

medium📝 Command Output Q4 of 15
Kubernetes - Labels and Selectors
Given these pods with labels:
pod1: app=web, env=prod
pod2: app=web, env=dev
What will kubectl get pods -l env=prod return?
ABoth pod1 and pod2
BOnly pod1
COnly pod2
DNo pods
Step-by-Step Solution
Solution:
  1. Step 1: Understand label selector usage

    The command selects pods with label 'env=prod'.
  2. Step 2: Match pods with label

    pod1 has 'env=prod', pod2 has 'env=dev'. Only pod1 matches.
  3. Final Answer:

    Only pod1 -> Option B
  4. Quick Check:

    Label selector returns matching pods = A [OK]
Quick Trick: Label selectors filter resources by matching key-value pairs [OK]
Common Mistakes:
  • Selecting pods with non-matching labels
  • Assuming all pods are returned
  • Confusing label keys and values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes