File tree 1 file changed +25
-3
lines changed
1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ Here are several detailed use cases for affinity that highlight its diverse appl
66
66
=== "Pod affinity"
67
67
### Pods scheduled together
68
68
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.
70
70
71
71
```sh
72
72
affinity:
@@ -77,16 +77,38 @@ Here are several detailed use cases for affinity that highlight its diverse appl
77
77
- key: app
78
78
operator: In
79
79
values:
80
- - nginx
80
+ - haProxy
81
81
topologyKey: "kubernetes.io/hostname"
82
82
```
83
83
84
84
??? 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 `.
86
86
87
87
- If no nodes match, the pod will not be scheduled until a suitable node becomes available.
88
88
89
89
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.
90
112
91
113
92
114
You can’t perform that action at this time.
0 commit comments