Which Pod specification field ensures the pod is scheduled only on nodes with matching labels?

Prepare for the Kubernetes Cloud Native Associate (KCNA) Certification test with engaging questions and detailed explanations. Perfect your knowledge and boost your confidence to pass the exam successfully!

Multiple Choice

Which Pod specification field ensures the pod is scheduled only on nodes with matching labels?

Explanation:
Node labeling is used to describe characteristics of nodes, and the nodeSelector field in a pod spec enforces those characteristics during scheduling. The scheduler will only consider nodes whose labels match all the key-value pairs specified in the nodeSelector. For example, using: spec: nodeSelector: disktype: ssd means the pod will be scheduled only on nodes that have the label disktype=ssd. If no such node exists, the pod stays Pending. This is distinct from pinning a pod to a specific node by name, choosing a different scheduler, or tolerating taints. For more complex constraints, nodeAffinity offers more expressive rules, but nodeSelector provides the straightforward label-based constraint.

Node labeling is used to describe characteristics of nodes, and the nodeSelector field in a pod spec enforces those characteristics during scheduling. The scheduler will only consider nodes whose labels match all the key-value pairs specified in the nodeSelector. For example, using:

spec:

nodeSelector:

disktype: ssd

means the pod will be scheduled only on nodes that have the label disktype=ssd. If no such node exists, the pod stays Pending. This is distinct from pinning a pod to a specific node by name, choosing a different scheduler, or tolerating taints. For more complex constraints, nodeAffinity offers more expressive rules, but nodeSelector provides the straightforward label-based constraint.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy