Bird
0
0

How can you combine node affinity and pod anti-affinity to ensure pods run on nodes labeled ssd=true but never on the same node as pods labeled app=db?

hard📝 Workflow Q9 of 15
Kubernetes - Scheduling
How can you combine node affinity and pod anti-affinity to ensure pods run on nodes labeled ssd=true but never on the same node as pods labeled app=db?
AUse preferredDuringSchedulingIgnoredDuringExecution nodeAffinity for ssd=true and preferredDuringSchedulingIgnoredDuringExecution podAffinity for app=db
BUse requiredDuringSchedulingIgnoredDuringExecution nodeAffinity for ssd=true and requiredDuringSchedulingIgnoredDuringExecution podAntiAffinity for app=db with hostname topologyKey
CUse requiredDuringSchedulingIgnoredDuringExecution podAffinity for ssd=true and requiredDuringSchedulingIgnoredDuringExecution nodeAntiAffinity for app=db
DUse preferredDuringSchedulingIgnoredDuringExecution podAntiAffinity for ssd=true and requiredDuringSchedulingIgnoredDuringExecution nodeAffinity for app=db
Step-by-Step Solution
Solution:
  1. Step 1: Set node affinity for nodes with ssd=true

    Use requiredDuringSchedulingIgnoredDuringExecution nodeAffinity to ensure pods only run on nodes labeled ssd=true.
  2. Step 2: Set pod anti-affinity to avoid co-locating with app=db pods

    Use requiredDuringSchedulingIgnoredDuringExecution podAntiAffinity with label app=db and topologyKey kubernetes.io/hostname to prevent same node placement.
  3. Final Answer:

    Use requiredDuringSchedulingIgnoredDuringExecution nodeAffinity for ssd=true and requiredDuringSchedulingIgnoredDuringExecution podAntiAffinity for app=db with hostname topologyKey -> Option B
  4. Quick Check:

    Combine required nodeAffinity + podAntiAffinity for strict placement [OK]
Quick Trick: Combine required nodeAffinity and podAntiAffinity for strict rules [OK]
Common Mistakes:
  • Mixing podAffinity with nodeAffinity incorrectly
  • Using preferred instead of required for strict rules
  • Confusing nodeAntiAffinity with podAntiAffinity

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes