You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/concepts/scheduling-eviction/assign-pod-node.md
+25-25Lines changed: 25 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,7 @@ define. Some of the benefits of affinity and anti-affinity include:
96
96
The affinity feature consists of two types of affinity:
97
97
98
98
-*Node affinity* functions like the `nodeSelector` field but is more expressive and
99
-
allows you to specify soft rules.
99
+
allows you to specify soft rules.
100
100
-*Inter-pod affinity/anti-affinity* allows you to constrain Pods against labels
101
101
on other Pods.
102
102
@@ -305,22 +305,22 @@ Pod affinity rule uses the "hard"
305
305
`requiredDuringSchedulingIgnoredDuringExecution`, while the anti-affinity rule
306
306
uses the "soft" `preferredDuringSchedulingIgnoredDuringExecution`.
307
307
308
-
The affinity rule specifies that the scheduler is allowed to place the example Pod
308
+
The affinity rule specifies that the scheduler is allowed to place the example Pod
309
309
on a node only if that node belongs to a specific [zone](/docs/concepts/scheduling-eviction/topology-spread-constraints/)
310
-
where other Pods have been labeled with `security=S1`.
311
-
For instance, if we have a cluster with a designated zone, let's call it "Zone V,"
312
-
consisting of nodes labeled with `topology.kubernetes.io/zone=V`, the scheduler can
313
-
assign the Pod to any node within Zone V, as long as there is at least one Pod within
314
-
Zone V already labeled with `security=S1`. Conversely, if there are no Pods with `security=S1`
310
+
where other Pods have been labeled with `security=S1`.
311
+
For instance, if we have a cluster with a designated zone, let's call it "Zone V,"
312
+
consisting of nodes labeled with `topology.kubernetes.io/zone=V`, the scheduler can
313
+
assign the Pod to any node within Zone V, as long as there is at least one Pod within
314
+
Zone V already labeled with `security=S1`. Conversely, if there are no Pods with `security=S1`
315
315
labels in Zone V, the scheduler will not assign the example Pod to any node in that zone.
316
316
317
-
The anti-affinity rule specifies that the scheduler should try to avoid scheduling the Pod
317
+
The anti-affinity rule specifies that the scheduler should try to avoid scheduling the Pod
318
318
on a node if that node belongs to a specific [zone](/docs/concepts/scheduling-eviction/topology-spread-constraints/)
319
-
where other Pods have been labeled with `security=S2`.
320
-
For instance, if we have a cluster with a designated zone, let's call it "Zone R,"
321
-
consisting of nodes labeled with `topology.kubernetes.io/zone=R`, the scheduler should avoid
322
-
assigning the Pod to any node within Zone R, as long as there is at least one Pod within
323
-
Zone R already labeled with `security=S2`. Conversely, the anti-affinity rule does not impact
319
+
where other Pods have been labeled with `security=S2`.
320
+
For instance, if we have a cluster with a designated zone, let's call it "Zone R,"
321
+
consisting of nodes labeled with `topology.kubernetes.io/zone=R`, the scheduler should avoid
322
+
assigning the Pod to any node within Zone R, as long as there is at least one Pod within
323
+
Zone R already labeled with `security=S2`. Conversely, the anti-affinity rule does not impact
324
324
scheduling into Zone R if there are no Pods with `security=S2` labels.
325
325
326
326
To get yourself more familiar with the examples of Pod affinity and anti-affinity,
@@ -371,12 +371,12 @@ When you want to use it, you have to enable it via the
371
371
{{< /note >}}
372
372
373
373
Kubernetes includes an optional `matchLabelKeys` field for Pod affinity
374
-
or anti-affinity. The field specifies keys for the labels that should match with the incoming Pod's labels,
374
+
or anti-affinity. The field specifies keys for the labels that should match with the incoming Pod's labels,
375
375
when satisfying the Pod (anti)affinity.
376
376
377
377
The keys are used to look up values from the pod labels; those key-value labels are combined
378
378
(using `AND`) with the match restrictions defined using the `labelSelector` field. The combined
379
-
filtering selects the set of existing pods that will be taken into Pod (anti)affinity calculation.
379
+
filtering selects the set of existing pods that will be taken into Pod (anti)affinity calculation.
380
380
381
381
A common use case is to use `matchLabelKeys` with `pod-template-hash` (set on Pods
382
382
managed as part of a Deployment, where the value is unique for each revision).
@@ -405,7 +405,7 @@ spec:
405
405
# Only Pods from a given rollout are taken into consideration when calculating pod affinity.
406
406
# If you update the Deployment, the replacement Pods follow their own affinity rules
407
407
# (if there are any defined in the new Pod template)
408
-
matchLabelKeys:
408
+
matchLabelKeys:
409
409
- pod-template-hash
410
410
```
411
411
@@ -422,7 +422,7 @@ When you want to use it, you have to enable it via the
422
422
{{< /note >}}
423
423
424
424
Kubernetes includes an optional `mismatchLabelKeys` field for Pod affinity
425
-
or anti-affinity. The field specifies keys for the labels that should **not** match with the incoming Pod's labels,
425
+
or anti-affinity. The field specifies keys for the labels that should **not** match with the incoming Pod's labels,
426
426
when satisfying the Pod (anti)affinity.
427
427
428
428
One example use case is to ensure Pods go to the topology domain (node, zone, etc) where only Pods from the same tenant or team are scheduled in.
@@ -438,22 +438,22 @@ metadata:
438
438
...
439
439
spec:
440
440
affinity:
441
-
podAffinity:
441
+
podAffinity:
442
442
requiredDuringSchedulingIgnoredDuringExecution:
443
443
# ensure that pods associated with this tenant land on the correct node pool
444
444
- matchLabelKeys:
445
445
- tenant
446
446
topologyKey: node-pool
447
-
podAntiAffinity:
447
+
podAntiAffinity:
448
448
requiredDuringSchedulingIgnoredDuringExecution:
449
449
# ensure that pods associated with this tenant can't schedule to nodes used for another tenant
450
450
- mismatchLabelKeys:
451
-
- tenant # whatever the value of the "tenant" label for this Pod, prevent
451
+
- tenant # whatever the value of the "tenant" label for this Pod, prevent
452
452
# scheduling to nodes in any pool where any Pod from a different
453
453
# tenant is running.
454
454
labelSelector:
455
455
# We have to have the labelSelector which selects only Pods with the tenant label,
456
-
# otherwise this Pod would hate Pods from daemonsets as well, for example,
456
+
# otherwise this Pod would hate Pods from daemonsets as well, for example,
457
457
# which aren't supposed to have the tenant label.
458
458
matchExpressions:
459
459
- key: tenant
@@ -633,13 +633,13 @@ The following operators can only be used with `nodeAffinity`.
633
633
634
634
| Operator | Behaviour |
635
635
| :------------: | :-------------: |
636
-
| `Gt` | The supplied value will be parsed as an integer, and that integer is less than the integer that results from parsing the value of a label named by this selector |
637
-
| `Lt` | The supplied value will be parsed as an integer, and that integer is greater than the integer that results from parsing the value of a label named by this selector |
636
+
| `Gt` | The supplied value will be parsed as an integer, and that integer is less than the integer that results from parsing the value of a label named by this selector |
637
+
| `Lt` | The supplied value will be parsed as an integer, and that integer is greater than the integer that results from parsing the value of a label named by this selector |
638
638
639
639
640
640
{{}}
641
-
`Gt`and `Lt` operators will not work with non-integer values. If the given value
642
-
doesn't parse as an integer, the pod will fail to get scheduled. Also, `Gt` and `Lt`
641
+
`Gt`and `Lt` operators will not work with non-integer values. If the given value
642
+
doesn't parse as an integer, the pod will fail to get scheduled. Also, `Gt` and `Lt`
0 commit comments