Affinity schedules a pod toward nodes matching declared labels or resource characteristics. In Kubeflow notebooks, it helps operators direct workloads to suitable nodes, including nodes reserved for GPUs or different CPU capacities. section 7.1.3 section 7.1.4
Use affinity to make notebook placement explicit and operationally manageable:
- Match node labels through node affinity rules; the example selects nodes whose compute label is small or xl. section 7.1.4
- Expose several configurations in the Kubeflow UI, or make a default configuration read-only to limit launch locations. section 7.1.4
- Combine affinity with taints and tolerations when powerful or specialized nodes must be restricted rather than merely preferred. section 7.1.3 section 7.1.4
Balancing small and powerful CPU nodes
Offer small-cpu-node and xl-cpu-node choices. Default ordinary notebooks to nodes labeled compute=small, while allowing workloads that need more capacity to select compute=xl. Because the shown affinity rule targets matching nodes without pairing it with a taint, an xl node can still accept pods when smaller nodes are full. section 7.1.4
Listing 7.3 Node affinity ConfigMap
affinityConfig:
value: ""
options:
- configKey: "small-cpu-selector"
displayName: "small-cpu-node"
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "compute"
operator: "In"
values:
- "small"
- configKey: "xl-cpu-selector"
displayName: "xl-cpu-node"
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "compute"
operator: "In"
values:
- "xl"
Inspect the complete ConfigMap structure for two node-affinity choices using requiredDuringSchedulingIgnoredDuringExecution and nodeSelectorTerms. section 7.1.4





