Config - Node Affinity Flashcards
What is Node Affinity used for?
- to make sure, that pods are hosted on specific nodes
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?
- simply checks, if the specified label exists on the node
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?
- requiredDuringSchedulingIgnoredDuringExecution:
- preferredDuringSchedulingIgnoredDuringExecution
What does the Type of NodeAffinity determine?
- defines the behavior of the scheduler in respect to NodeAffinity and the stages in the lifecycle of the pod
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 pod-placement is crucial
- if not possible to deploy than no pod will be deployed
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:
- Apply Taints
- Apply Tolerations
- Use NodeAffinity, so that only the wanted applications can select the nodes