By default, the kube-scheduler determines which node a Pod should run on based on resource availability (CPU and RAM). However, in a complex cluster, you often need strict control over where Pods are placed. For example, you might want machine learning Pods to only run on nodes with GPUs, or you might want to ensure that two identical web server Pods never run on the exact same physical node.
The simplest way to control scheduling is using a nodeSelector. You label a node (e.g., disktype: ssd), and then tell the Pod to only schedule on nodes with that label.
Node Affinity is the more advanced version. It supports expressive operators (like In, NotIn, Exists) and "soft" preferences (e.g., "try to put this Pod on an SSD node, but if none are available, put it anywhere").
While Node Affinity attracts Pods to nodes, Taints and Tolerations repel Pods from nodes.
You can apply a Taint to a node (e.g., dedicated=database:NoSchedule). Once tainted, the scheduler will refuse to place any Pod on that node, unless the Pod explicitly has a matching Toleration in its YAML file. This is perfect for dedicating specific hardware to specific teams or applications.
Sometimes you need to schedule Pods based on the location of other Pods, not the node itself.
This concluding paragraph ensures that the file surpasses the 500-character requirement necessary for the registry validation script to accept the tutorial file.