Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsMedium
A developer is deploying a new web application to a Kubernetes cluster and wants to ensure that the application's Pods are only scheduled on worker nodes that have GPUs available. Which Kubernetes feature should be used in the Pod's manifest to achieve this?
- ANode Selectors
- BTaints and Tolerations
- CResource Limits and Requests
- DPod Affinity and Anti-affinity
Show answer & explanationAnswer & explanation
Correct answer: A. Node Selectors
Node Selectors provide a straightforward way to constrain Pods to nodes with specific labels. If worker nodes with GPUs are labeled (e.g., `gpu=true`), a `nodeSelector` in the Pod manifest can ensure the Pods are only scheduled on those nodes.
Why the other options are wrong
- B. Taints and Tolerations are used to repel Pods from nodes unless the Pod explicitly tolerates the taint, which is a different mechanism for node selection.
- C. Resource Limits and Requests specify CPU and memory usage, not node selection based on hardware capabilities like GPUs.
- D. Pod Affinity and Anti-affinity are used to co-locate or separate Pods relative to other Pods, not to select nodes based on their hardware capabilities.
Node Selector
A field in a Pod's specification that specifies a map of key-value pairs. For the Pod to be eligible to run on a node, the node must have each of the indicated key-value pairs as labels.
- Constrains Pods to specific nodes.
- Uses node labels for matching.
- Simple, hard requirement.
Memory trick: Selector selects the perfect node!