You need to ensure a Pod runs on a specific node. What mechanism should you use?
- nodeSelector field in Pod spec
- kubectl exec on the node
- Pod affinity rules
- nodeName field in Pod spec ✓
Correct answer: nodeName field in Pod spec
Option D, nodeName, directly assigns a Pod to a specific node by name at scheduling time, bypassing the scheduler entirely and guaranteeing placement on that exact node. Option A, nodeSelector, filters nodes by labels rather than specifying a node by name, so it selects from a group of matching nodes rather than pinning to one specific node. Option B, kubectl exec, is a runtime debugging command used to open a shell inside a running container and has no bearing on scheduling decisions. Option C, Pod affinity rules, express preferences or requirements based on the labels of other Pods already running on nodes, not on directly targeting a named node.
Topic: · kubernetes, pod scheduling, nodename, node assignment