Bird
0
0

You want to schedule pods so that each pod runs on a different node but all pods remain within the same availability zone. Which affinity and topologyKey configuration achieves this?

hard📝 Workflow Q8 of 15
Kubernetes - Scheduling
You want to schedule pods so that each pod runs on a different node but all pods remain within the same availability zone. Which affinity and topologyKey configuration achieves this?
AUse <code>podAntiAffinity</code> with <code>preferredDuringSchedulingIgnoredDuringExecution</code> and <code>topologyKey: failure-domain.beta.kubernetes.io/region</code>.
BUse <code>podAffinity</code> with <code>requiredDuringSchedulingIgnoredDuringExecution</code> and <code>topologyKey: failure-domain.beta.kubernetes.io/zone</code>.
CUse <code>podAntiAffinity</code> with <code>requiredDuringSchedulingIgnoredDuringExecution</code> and <code>topologyKey: kubernetes.io/hostname</code>, combined with <code>nodeAffinity</code> restricting nodes to the desired zone label.
DUse <code>podAffinity</code> with <code>preferredDuringSchedulingIgnoredDuringExecution</code> and <code>topologyKey: kubernetes.io/hostname</code>.
Step-by-Step Solution
Solution:
  1. Step 1: Ensure pods run on different nodes

    Using podAntiAffinity with requiredDuringSchedulingIgnoredDuringExecution and topologyKey: kubernetes.io/hostname prevents pods from scheduling on the same node.
  2. Step 2: Restrict pods to the same zone

    Use nodeAffinity to limit scheduling to nodes labeled with the desired availability zone.
  3. Step 3: Combine both rules

    This combination ensures pods are spread across nodes but remain within the same zone.
  4. Final Answer:

    Use podAntiAffinity with requiredDuringSchedulingIgnoredDuringExecution and topologyKey: kubernetes.io/hostname, combined with nodeAffinity restricting nodes to the desired zone label. correctly achieves the requirement.
  5. Quick Check:

    Anti-affinity by hostname + nodeAffinity by zone [OK]
Quick Trick: Combine podAntiAffinity by hostname with nodeAffinity by zone [OK]
Common Mistakes:
  • Using podAffinity instead of podAntiAffinity to spread pods
  • Using preferred instead of required for strict spreading
  • Using region instead of zone for topologyKey

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes