Bird
0
0

To ensure that no two pods with label app=web are scheduled on the same node, which pod anti-affinity configuration should you use?

hard📝 Workflow Q8 of 15
Kubernetes - Scheduling
To ensure that no two pods with label app=web are scheduled on the same node, which pod anti-affinity configuration should you use?
ApodAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: app: web topologyKey: "kubernetes.io/hostname"
BpodAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 labelSelector: matchLabels: app: web topologyKey: "zone"
CnodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: app operator: NotIn values: - web
DpodAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 1 labelSelector: matchLabels: app: web topologyKey: "zone"
Step-by-Step Solution
Solution:
  1. Step 1: Understand requirement

    Pods with label app=web must never co-locate on the same node.
  2. Step 2: Use pod anti-affinity

    Required pod anti-affinity with topologyKey: kubernetes.io/hostname enforces this at node level.
  3. Step 3: Eliminate incorrect options

    podAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 labelSelector: matchLabels: app: web topologyKey: "zone" uses pod affinity, not anti-affinity. nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: app operator: NotIn values: - web uses node affinity incorrectly. podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 1 labelSelector: matchLabels: app: web topologyKey: "zone" uses preferred anti-affinity which is not guaranteed.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    Required pod anti-affinity with hostname topologyKey prevents co-location [OK]
Quick Trick: Use required podAntiAffinity with hostname topologyKey to separate pods [OK]
Common Mistakes:
  • Using preferred instead of required anti-affinity
  • Confusing podAffinity with podAntiAffinity
  • Using wrong topologyKey for node-level separation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes