Recall & Review
beginner
What is node affinity in Kubernetes?
Node affinity is a set of rules used by Kubernetes to schedule pods onto nodes based on node labels. It helps pods prefer or require certain nodes to run on.
Click to reveal answer
beginner
What does node anti-affinity do?
Node anti-affinity tells Kubernetes to avoid placing pods on nodes with certain labels. It helps spread pods across nodes to improve availability.
Click to reveal answer
intermediate
What are the two types of node affinity in Kubernetes?
The two types are requiredDuringSchedulingIgnoredDuringExecution (hard requirement) and preferredDuringSchedulingIgnoredDuringExecution (soft preference).
Click to reveal answer
intermediate
How does Kubernetes treat requiredDuringSchedulingIgnoredDuringExecution node affinity?
It treats it as a hard rule. Pods will only be scheduled on nodes that meet the specified label criteria.
Click to reveal answer
beginner
Give a simple example of node affinity in a pod spec.
Example snippet:<br>
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "disktype"
operator: In
values:
- ssdClick to reveal answer
What does node anti-affinity help achieve?
✗ Incorrect
Node anti-affinity helps avoid placing pods on nodes with certain labels to spread pods and improve availability.
Which node affinity type is a hard requirement?
✗ Incorrect
requiredDuringSchedulingIgnoredDuringExecution is a hard rule that must be met for scheduling.
What Kubernetes object label is used in node affinity to select nodes?
✗ Incorrect
Node affinity uses node labels to decide where pods should be scheduled.
If a pod has node affinity with preferredDuringSchedulingIgnoredDuringExecution, what happens if no nodes match?
✗ Incorrect
Preferred affinity is a soft preference; if no nodes match, pod can schedule anywhere.
Which section in a pod spec defines node affinity?
✗ Incorrect
Node affinity rules are defined under spec.affinity.nodeAffinity in the pod spec.
Explain node affinity and anti-affinity in Kubernetes and how they affect pod scheduling.
Think about how pods choose nodes based on labels and preferences.
You got /4 concepts.
Describe a scenario where you would use node anti-affinity and why it is useful.
Consider how spreading pods can prevent single points of failure.
You got /3 concepts.