Config - Node Affinity Flashcards

1
Q

What is Node Affinity used for?

A
  • to make sure, that pods are hosted on specific nodes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do we specify Node Affinity for pods?

A

pod-yaml:

spec:
  containers:
	  - name: 
	  image:
affinity:
  nodeAffinity:
	  requiredDuringSchedulingIgnoredDuringExecution:
		  nodeSelectorTerms:
			  - matchExpressions:
			    - key: size
			      operator: In (alt: NotIn)
						values:
						  - Large
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the Exists operator do?

A
  • simply checks, if the specified label exists on the node
spec:
  ...
	affinity:
	  nodeAffinity:
		  requiredDuringSchedulingIgnoredDuringExecution:
			  nodeSelectorTerms:
				  - matchExpressions:
				    - key: size
				      operator: Exists
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What if NodeAffinity can not match a node with the given expression?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are Types of Node Affinity?

A
  • requiredDuringSchedulingIgnoredDuringExecution:
  • preferredDuringSchedulingIgnoredDuringExecution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the Type of NodeAffinity determine?

A
  • defines the behavior of the scheduler in respect to NodeAffinity and the stages in the lifecycle of the pod
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When is NodeAffinity being considered?

A

in two phases, during scheduling and during execution

During Scheduling: when pod is created for the first time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When do you use the NodeAffinity Type
requiredDuringSchedulingIgnoredDuringExecution?

A
  • when pod-placement is crucial
  • if not possible to deploy than no pod will be deployed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When do you use the NodeAffinity Type
preferredDuringSchedulingIgnoredDuringExecution?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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?

A

By using a combination of Taints/Tolerations and Node Affinity:

  1. Apply Taints
  2. Apply Tolerations
  3. Use NodeAffinity, so that only the wanted applications can select the nodes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly