Complete a Deployment so its Pods run only on the dedicated GPU node pool.
A GPU node pool is tainted dedicated=gpu:NoSchedule and its nodes carry the label accelerator=gpu. The Deployment below currently schedules nowhere on that pool. Add exactly what is needed so its Pods run ONLY on the GPU nodes — remember a toleration alone does not attract a Pod.
spec:
template:
spec:
containers:
- name: trainer
image: "trainer:1.4"
# TODO: make these Pods run only on the tainted GPU nodes
Add the missing tolerations and affinity. Do not remove the container.
Add BOTH: a toleration matching the taint so GPU nodes stop repelling the Pod, and a required nodeAffinity on accelerator=gpu so it is attracted only there. The toleration alone merely permits GPU nodes; without affinity the Pod could still land on any untainted node. Together they pin it to the pool.
- ✗Adding only a toleration and expecting it to attract the Pod
- ✗Adding only nodeAffinity and hitting the untolerated
NoScheduletaint - ✗Believing affinity overrides a taint, so no toleration is needed
- →How would you keep general Pods OFF the GPU nodes at the same time?
- →When is
preferredDuringSchedulingaffinity the better choice here?
Both parts are needed because taints and affinity are orthogonal. The toleration lifts the NoSchedule bar but does not attract the Pod; nodeAffinity attracts the Pod to nodes labelled accelerator=gpu. Without the affinity, a Pod that merely tolerates the taint could still land on any untainted general node.
spec:
template:
spec:
containers:
- name: trainer
image: "trainer:1.4"
tolerations:
- key: dedicated
operator: Equal
value: gpu
effect: NoSchedule
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: accelerator
operator: In
values: ["gpu"]