mediumMultiple Choice
CKS Practice Question: Ensure that a pod only runs on nodes that have a…
You want to ensure that a pod only runs on nodes that have a specific label, 'disktype=ssd'. Which field should be specified in the pod spec?
⚠ Common exam trap
CNCF often tests the distinction between `nodeSelector` (simple label match) and `nodeAffinity` (advanced label matching with operators), leading candidates to overcomplicate and choose `nodeAffinity` when `nodeSelector` is the correct, minimal answer.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
nodeSelector
C is correct because `nodeSelector` is the simplest and most direct field in a Pod spec for constraining which nodes the Pod can be scheduled on based on node labels. By setting `nodeSelector` with `disktype: ssd`, the scheduler will only place the Pod on nodes that have that exact label key-value pair, making it the ideal choice for this straightforward label-based scheduling requirement.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
affinity.nodeAffinity
Why it's wrong here
`affinity.nodeAffinity` is the parent field for defining both required and preferred node scheduling rules. However, simply specifying `affinity.nodeAffinity` without its `requiredDuringSchedulingIgnoredDuringExecution` sub-field does not guarantee the pod will *only* run on nodes with the specified label. While tempting as it directly addresses node label-based scheduling, this option alone doesn't enforce the strict "only runs" constraint. It is correctly used when you want to define either mandatory or preferential node selection criteria, with the specific enforcement mechanism defined within its sub-fields.
- ✗
nodeName
Why it's wrong here
nodeName directly assigns the pod to a specific node by its unique name, such as `node-abc`, completely bypassing the scheduler's label-based selection logic. It does not use labels at all, so it cannot express a requirement like "any node with label disktype=ssd" — it only ever targets one named node. Additionally, if that named node is unschedulable or becomes unavailable, the pod fails to schedule even if other matching-label nodes exist, making it unsuitable for label-restricted placement.
- ✓
nodeSelector
Why this is correct
nodeSelector is a straightforward pod spec field that restricts the pod to nodes carrying all the specified label key-value pairs. The scheduler treats this as a hard constraint: if no node has the required labels, the pod remains Pending and is never scheduled onto a mismatched node. This exactly satisfies the need to ensure the pod runs only on nodes with a given label, as it enforces the label match at scheduling time without requiring additional configuration.
- ✗
tolerations
Why it's wrong here
tolerations are designed to allow a pod to be scheduled onto nodes that have matching taints, which by default repel pods. They are not label-based selectors; instead, they indicate that the pod can tolerate a node's taint, thereby expanding the set of schedulable nodes rather than narrowing it. Therefore, tolerations alone cannot ensure the pod runs only on nodes with a specific label, because they neither reference labels nor impose any restriction on which untainted nodes are eligible.
Go deeper
Related to this question
About these practice questions
This CKS question is part of Courseiva's 845-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKS practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKS exam.