‹ All CKA questions

CKA Practice Question 3: Taints Tolerations Versus Affinity

Certified Kubernetes Administrator (CKA) · Test 1 · question 3 of 10

Schedulingmedium

A cluster has 3 nodes with GPUs, labelled hardware=gpu, and 12 nodes without. You need two things to be true: GPU workloads must run only on the GPU nodes, and all other workloads must be kept off those GPU nodes so the expensive hardware is not consumed by general-purpose pods.

Which approach achieves both requirements?

Select one answer
Show answer and explanation

Answer:

  • C. Taint the GPU nodes, and give the GPU workloads both a matching toleration and a nodeSelector of hardware=gpu

Taints and tolerations, and node affinity, solve opposite halves of this problem, and this scenario needs both.

A taint on the GPU nodes repels every pod that does not tolerate it, which keeps general-purpose workloads off. But a toleration only makes a pod eligible for a tainted node; it does not attract it. A tolerating pod is still free to be scheduled onto any of the 12 ordinary nodes. The nodeSelector (or a requiredDuringSchedulingIgnoredDuringExecution node affinity) is what actually pins the GPU workloads to the GPU nodes.

Option A satisfies only the first requirement: GPU workloads land on GPU nodes, but nothing stops other pods from being scheduled there too.

Option B satisfies only the second: other workloads are repelled, but GPU workloads may still be scheduled onto non-GPU nodes, where they will fail to find a GPU.

Option D misuses pod anti-affinity, which schedules pods relative to other pods, not to node hardware. Any non-GPU node that happens to run no GPU workload would still accept general workloads onto GPU hardware, and the rule breaks down as soon as a GPU node is empty.

Reference: Taints and Tolerations

Practice Test 1 ›

Study guides for CKA