Bird
0
0

How would you select pods that have label 'version' set to either 'v1' or 'v2' but exclude those with label 'env' equal to 'test'?

hard📝 Workflow Q9 of 15
Kubernetes - Labels and Selectors
How would you select pods that have label 'version' set to either 'v1' or 'v2' but exclude those with label 'env' equal to 'test'?
Aversion in (v1, v2), env notin (test)
Bversion in (v1, v2) env notin (test)
Cversion in (v1, v2), env notin test
Dversion= v1 or v2, env!=test
Step-by-Step Solution
Solution:
  1. Step 1: Use set-based selector for 'version'

    version in (v1, v2) selects pods with version 'v1' or 'v2'.
  2. Step 2: Exclude pods with env='test'

    env notin (test) excludes pods where env equals 'test'.
  3. Final Answer:

    version in (v1, v2), env notin (test) -> Option A
  4. Quick Check:

    Combine 'in' and 'notin' with commas [OK]
Quick Trick: Combine 'in' and 'notin' with commas for complex selectors [OK]
Common Mistakes:
  • Omitting commas between selectors
  • Using 'or' instead of commas
  • Incorrect syntax for exclusion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes