Bird
0
0

You wrote this Service YAML:

medium📝 Troubleshoot Q6 of 15
Kubernetes - Services
You wrote this Service YAML:
selector:
  app: frontend
  env: staging
But the Service does not route traffic to any pods. What is the likely problem?
AThe selector key should be <code>matchLabels</code> instead of <code>selector</code>
BPods do not have both labels <code>app=frontend</code> and <code>env=staging</code>
CThe Service must specify <code>podSelector</code> instead of <code>selector</code>
DThe labels in selector must be comma separated
Step-by-Step Solution
Solution:
  1. Step 1: Check selector syntax correctness

    The selector syntax is correct; selector with key-value pairs is valid.
  2. Step 2: Identify why no pods are selected

    If no pods match both labels exactly, the Service routes to no pods.
  3. Final Answer:

    Pods do not have both labels app=frontend and env=staging -> Option B
  4. Quick Check:

    No matching pods = labels mismatch [OK]
Quick Trick: No traffic? Check pods have all selector labels exactly [OK]
Common Mistakes:
  • Confusing selector syntax with matchLabels
  • Using wrong selector key names
  • Expecting comma-separated labels in YAML

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes