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

Prepare for the KCNA Certification Test. Study with flashcards, multiple-choice questions, and detailed explanations to enhance your understanding of Kubernetes Cloud Native concepts. Ace your exam!

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