What is Node Affinity used for?
How do we specify Node Affinity for pods?
pod-yaml:
spec: containers: - name: image: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: size operator: In (alt: NotIn) values: - Large
What does the Exists operator do?
spec: ... affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: size operator: Exists
What if NodeAffinity can not match a node with the given expression?
What are Types of Node Affinity?
What does the Type of NodeAffinity determine?
When is NodeAffinity being considered?
in two phases, during scheduling and during execution
During Scheduling: when pod is created for the first time
When do you use the NodeAffinity Type
requiredDuringSchedulingIgnoredDuringExecution?
When do you use the NodeAffinity Type
preferredDuringSchedulingIgnoredDuringExecution?
When the pod placement is less important than the workload itself
- if no matching node is found, NodeAffinity Rules will be ignored and place the pod on any available node
Given, that we have other nodes in the cluster where we dont want certain applications to run as well as applications that we dont want to run on certain nodes, how do we accomplish that?
By using a combination of Taints/Tolerations and Node Affinity: