Bird
0
0

Given this Service selector:

medium📝 Command Output Q4 of 15
Kubernetes - Services
Given this Service selector:
selector:
  role: db
  env: prod
Which pods will this Service route traffic to?
APods with label <code>env=prod</code> only
BPods with label <code>role=db</code> only
CPods with labels <code>role=db</code> and <code>env=prod</code>
DPods with either <code>role=db</code> or <code>env=prod</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand selector matching logic

    A Service selector matches pods that have all specified labels with exact values.
  2. Step 2: Apply to given selector

    Pods must have both role=db and env=prod labels to be selected.
  3. Final Answer:

    Pods with labels role=db and env=prod -> Option C
  4. Quick Check:

    Selector matches pods with all labels specified [OK]
Quick Trick: Selector matches pods with all labels, not just one [OK]
Common Mistakes:
  • Assuming selector matches pods with any one label
  • Ignoring one of the labels in selector
  • Confusing AND with OR logic in selectors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes