Bird
0
0

Given this Service YAML snippet:

medium📝 Command Output Q13 of 15
Kubernetes - Labels and Selectors
Given this Service YAML snippet:
selector:
  app: backend
  tier: api

Which pods will this Service route traffic to?
APods labeled only with app=backend
BPods labeled with either app=backend or tier=api
CPods labeled with both app=backend and tier=api
DPods labeled only with tier=api
Step-by-Step Solution
Solution:
  1. Step 1: Understand selector matching

    Selectors match pods that have all specified labels (AND logic).
  2. Step 2: Apply to given labels

    Pods must have both app=backend and tier=api labels to be selected.
  3. Final Answer:

    Pods labeled with both app=backend and tier=api -> Option C
  4. Quick Check:

    Selector matches all labels (AND) = A [OK]
Quick Trick: Selectors match pods with all labels, not just one [OK]
Common Mistakes:
  • Assuming selector matches any label (OR logic)
  • Ignoring one of the labels in selector
  • Confusing selector with pod annotations

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes