Skip to content

Commit 0818764

Browse files
anti-affinity use case
1 parent 868ead8 commit 0818764

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

docs/use/affinity.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Here are several detailed use cases for affinity that highlight its diverse appl
6666
=== "Pod affinity"
6767
### Pods scheduled together
6868

69-
Let's consider a use case in which you want to to ensure that two nginx pods should be scheduled to run on the same Kubernetes node.
69+
Let's consider a use case in which you want to to ensure that HAProxy pods should be scheduled to run on the same Kubernetes node.
7070

7171
```sh
7272
affinity:
@@ -77,16 +77,38 @@ Here are several detailed use cases for affinity that highlight its diverse appl
7777
- key: app
7878
operator: In
7979
values:
80-
- nginx
80+
- haProxy
8181
topologyKey: "kubernetes.io/hostname"
8282
```
8383

8484
??? info "What happens under the hood"
85-
- The pod will be scheduled only on nodes that already contain pods labeled with `app=nginx`.
85+
- The pod will be scheduled only on nodes that already contain pods labeled with `app=haproxy`.
8686

8787
- If no nodes match, the pod will not be scheduled until a suitable node becomes available.
8888

8989

90+
=== "Pod anti-affinity"
91+
### Pods scheduled apart
92+
93+
Let's consider a use case in which you want to ensure that no HAProxy pods should be scheduled to run on the same Kubernetes node.
94+
95+
```sh
96+
affinity:
97+
podAntiAffinity:
98+
requiredDuringSchedulingIgnoredDuringExecution:
99+
- labelSelector:
100+
matchExpressions:
101+
- key: app
102+
operator: In
103+
values:
104+
- haproxy
105+
topologyKey: "kubernetes.io/hostname"
106+
```
107+
108+
??? info "What happens under the hood"
109+
- The pod will not be scheduled on nodes that contain pods labeled with `app=haproxy`.
110+
111+
- If no nodes match, the pod will not be scheduled until a suitable node becomes available.
90112

91113

92114

0 commit comments

Comments
 (0)