Bird
0
0

You want to select pods with label app=web or app=api. Which command achieves this?

hard📝 Workflow Q9 of 15
Kubernetes - Labels and Selectors
You want to select pods with label app=web or app=api. Which command achieves this?
Akubectl get pods -l 'app=web,env=staging'
Bkubectl get pods -l 'app=web,env=staging' --or
Ckubectl get pods -l 'app=web env=staging'
Dkubectl get pods -l 'app in (web, api)'
Step-by-Step Solution
Solution:
  1. Step 1: Understand label selector OR logic

    Comma-separated labels mean AND, not OR.
  2. Step 2: Use 'in' operator for OR condition

    The in operator allows selecting multiple values for the same label key (OR logic), like app in (web, api).
  3. Step 3: Identify correct command

    kubectl get pods -l 'app in (web, api)' selects pods labeled app=web or app=api.
  4. Final Answer:

    kubectl get pods -l 'app in (web, api)' -> Option D
  5. Quick Check:

    Use 'in' operator for OR conditions [OK]
Quick Trick: Use 'in' operator for OR label filtering [OK]
Common Mistakes:
  • Assuming commas mean OR
  • Using non-existent --or flag
  • Separating labels with spaces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes