KCNA Container Orchestration Practice Question
An application requires that a specific set of pods be placed on nodes labeled with 'gpu=true'. Which Kubernetes field should be used in the pod spec to enforce this?
⚠ Common exam trap
Watch out — candidates often confuse `nodeSelector` with `nodeAffinity`, thinking the more advanced field is always required, but the question specifically asks for the field that enforces placement on labeled nodes, and `nodeSelector` is the simplest and correct answer for a straightforward label match.
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
`nodeSelector` is the simplest and most direct Kubernetes field for constraining a pod to nodes that have a specific label. By setting `nodeSelector: { gpu: 'true' }` in the pod spec, the scheduler will only place the pod on nodes that have the label `gpu=true`. This is a hard constraint that does not support complex expressions but is ideal for the stated 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.
- ✓
nodeSelector
Why this is correct
nodeSelector matches pods to nodes using label key-value pairs, so specifying `gpu: "true"` restricts scheduling to nodes carrying that exact label. This directly satisfies the stem's requirement to enforce placement on `gpu=true` nodes, since the scheduler filters out any node lacking the matching label.
- ✗
topologySpreadConstraints
Why it's wrong here
topologySpreadConstraints distributes pods evenly across topology domains such as zones or nodes; it does not select nodes by label. It tempts when balancing replicas for availability, but enforcing placement on gpu=true nodes requires nodeAffinity or a nodeSelector matching that label.
- ✗
affinity.nodeAffinity
Why it's wrong here
nodeAffinity with a requiredDuringSchedulingIgnoredDuringExecution rule matching gpu=true is the correct mechanism, so this option is not the wrong one. It is listed here only because the question asks for the field that enforces label-based placement, which nodeAffinity satisfies.
- ✗
tolerations
Why it's wrong here
Tolerations allow pods to schedule onto nodes carrying matching taints; they do not select nodes by label. They tempt when workloads must run on dedicated or tainted nodes, but gpu=true is a label, so nodeAffinity or nodeSelector is required to enforce placement.
Go deeper
Related to this question
About these practice questions
Courseiva writes every KCNA question from scratch — 930 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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 KCNA 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 KCNA exam.