Skip to content

Commit 81fd15a

Browse files
Added section on operators for nodeAffinity and podAffinity (#39742)
* Added section in the docs about the behaviour of operator in the node and pod affinity docs * Fixes from review * Fixed podAffinity and added note about non-integer values * Fixes from review * Fixed review comments * Fixes from review
1 parent f3552a9 commit 81fd15a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

content/en/docs/concepts/scheduling-eviction/assign-pod-node.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ You can use the `operator` field to specify a logical operator for Kubernetes to
135135
interpreting the rules. You can use `In`, `NotIn`, `Exists`, `DoesNotExist`,
136136
`Gt` and `Lt`.
137137

138+
Read [Operators](#operators)
139+
to learn more about how these work.
140+
138141
`NotIn` and `DoesNotExist` allow you to define node anti-affinity behavior.
139142
Alternatively, you can use [node taints](/docs/concepts/scheduling-eviction/taint-and-toleration/)
140143
to repel Pods from specific nodes.
@@ -310,6 +313,9 @@ refer to the [design proposal](https://git.k8s.io/design-proposals-archive/sched
310313
You can use the `In`, `NotIn`, `Exists` and `DoesNotExist` values in the
311314
`operator` field for Pod affinity and anti-affinity.
312315

316+
Read [Operators](#operators)
317+
to learn more about how these work.
318+
313319
In principle, the `topologyKey` can be any allowed label key with the following
314320
exceptions for performance and security reasons:
315321

@@ -492,6 +498,31 @@ overall utilization.
492498
Read [Pod topology spread constraints](/docs/concepts/scheduling-eviction/topology-spread-constraints/)
493499
to learn more about how these work.
494500

501+
## Operators
502+
503+
The following are all the logical operators that you can use in the `operator` field for `nodeAffinity` and `podAffinity` mentioned above.
504+
505+
| Operator | Behavior |
506+
| :------------: | :-------------: |
507+
| `In` | The label value is present in the supplied set of strings |
508+
| `NotIn` | The label value is not contained in the supplied set of strings |
509+
| `Exists` | A label with this key exists on the object |
510+
| `DoesNotExist` | No label with this key exists on the object |
511+
512+
The following operators can only be used with `nodeAffinity`.
513+
514+
| Operator | Behaviour |
515+
| :------------: | :-------------: |
516+
| `Gt` | The supplied value will be parsed as an integer, and that integer is less than or equal to the integer that results from parsing the value of a label named by this selector |
517+
| `Lt` | The supplied value will be parsed as an integer, and that integer is greater than or equal to the integer that results from parsing the value of a label named by this selector |
518+
519+
520+
{{<note>}}
521+
`Gt` and `Lt` operators will not work with non-integer values. If the given value
522+
doesn't parse as an integer, the pod will fail to get scheduled. Also, `Gt` and `Lt`
523+
are not available for `podAffinity`.
524+
{{</note>}}
525+
495526
## {{% heading "whatsnext" %}}
496527

497528
- Read more about [taints and tolerations](/docs/concepts/scheduling-eviction/taint-and-toleration/) .

0 commit comments

Comments
 (0)