Bird
0
0

Given this pod spec snippet, what will happen if a pod with label app: frontend is scheduled?

medium📝 Command Output Q13 of 15
Kubernetes - Scheduling
Given this pod spec snippet, what will happen if a pod with label app: frontend is scheduled?
affinity:
  podAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
    - labelSelector:
        matchLabels:
          app: backend
      topologyKey: kubernetes.io/hostname
AThe pod will be scheduled only if no pod with label app=backend exists
BThe pod will be scheduled on any node regardless of other pods
CThe pod will be scheduled on a node that already runs a pod with label app=backend
DThe pod scheduling will fail due to syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Understand required podAffinity behavior

    Required podAffinity means the pod must be placed on a node where pods with matching labels already run, here app=backend.
  2. Step 2: Apply to given pod spec

    The pod with label app=frontend requires a node with pods labeled app=backend, so it will schedule only on such nodes.
  3. Final Answer:

    The pod will be scheduled on a node that already runs a pod with label app=backend -> Option C
  4. Quick Check:

    Required podAffinity = schedule near matching pods [OK]
Quick Trick: Required podAffinity means schedule near matching pods [OK]
Common Mistakes:
  • Thinking podAffinity prevents scheduling near pods
  • Confusing required and preferred affinity
  • Assuming scheduling fails without matching pods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes