Node affinity

102

Node affinity is a property of Pods that attracts them to a set of nodes (either as a preference or a hard requirement).

Stuff you wanna know:

  1. Node affinity is conceptually similar to nodeSelector, allowing you to constrain which nodes your Pod can be scheduled on based on node labels.
  2. There are two types of node affinity:
    • requiredDuringSchedulingIgnoredDuringExecution: The scheduler can’t schedule the Pod unless the rule is met. This functions like nodeSelector, but with a more expressive syntax.
    • preferredDuringSchedulingIgnoredDuringExecution: The scheduler tries to find a node that meets the rule. If a matching node is not available, the scheduler still schedules the Pod.
  3. You can specify node affinities using the .spec.affinity.nodeAffinity field in your Pod spec.
  4. NotIn and DoesNotExist allow you to define node anti-affinity behavior.
  5. You can use node taints to repel Pods from specific nodes.
  6. If you specify both nodeSelector and nodeAffinity, both must be satisfied for the Pod to be scheduled onto a node.
  7. You can specify a weight between 1 and 100 for each instance of thepreferredDuringSchedulingIgnoredDuringExecution affinity type.
  8. When configuring multiple scheduling profiles, you can associate a profile with a node affinity, which is useful if a profile only applies to a specific set of nodes.
  9. Inter-pod affinity and anti-affinity allow you to constrain which nodes your Pods can be scheduled on based on the labels of Pods already running on that node, instead of the node labels.
  10. Inter-pod affinity and anti-affinity require substantial amount of processing which can slow down scheduling in large clusters significantly.

More stuff: