Bird
0
0

Given pods with labels:

medium📝 Command Output Q4 of 15
Kubernetes - Labels and Selectors
Given pods with labels:
pod1: app=frontend, env=prod
pod2: app=frontend, env=dev
What is the output of kubectl get pods -l app=frontend,env=prod?
ALists pod1 and pod2
BLists only pod1
CLists only pod2
DNo pods listed
Step-by-Step Solution
Solution:
  1. Step 1: Analyze label selector

    The command filters pods with both labels app=frontend and env=prod.
  2. Step 2: Match pods to labels

    Only pod1 has both labels; pod2 has env=dev, so it is excluded.
  3. Final Answer:

    Lists only pod1 -> Option B
  4. Quick Check:

    Label AND filter = pods matching all labels [OK]
Quick Trick: Label selectors with commas mean AND condition [OK]
Common Mistakes:
  • Assuming comma means OR
  • Listing pods missing one label
  • Confusing env=prod with env=dev

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes