Skip to content

Commit 8034a88

Browse files
authored
Merge branch 'master' into fullUrlImages
2 parents c52b591 + 3b366e0 commit 8034a88

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/cloud/rahti/tutorials/pod-affinity.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,38 @@ Labels: app=celery-worker
5353

5454
When the `affinity` block is added to this deployment, the scheduler will (re-)launch the Pods corresponding to `wes-deployment` into the same as `celery-worker` is running. As the policy used is `requiredDuringSchedulingIgnoredDuringExecution`, if there is no space in the chosen node, the deployment will not succeed. Other policy is `preferredDuringSchedulingIgnoredDuringExecution`, which means that the scheduling will not fail if there is no space in the chosen node as they will be scheduled in a different one.
5555

56+
Regarding the pod anti-affinity, the syntax is slightly different. Here is an example:
57+
58+
```diff
59+
diff --git a/charts/wes/templates/wes/wes-deployment.yaml b/charts/wes/templates/wes/wes-deployment.yaml
60+
index 93ca230..e64349b 100644
61+
--- a/charts/wes/templates/wes/wes-deployment.yaml
62+
+++ b/charts/wes/templates/wes/wes-deployment.yaml
63+
@@ -12,6 +12,16 @@ spec:
64+
labels:
65+
app: {{ .Values.wes.appName }}
66+
spec:
67+
+ affinity:
68+
+ podAntiAffinity:
69+
+ requiredDuringSchedulingIgnoredDuringExecution:
70+
+ - weight: 100
71+
+ podAffinityTerm:
72+
+ labelSelector:
73+
+ matchExpressions:
74+
+ - key: app
75+
+ operator: In
76+
+ values:
77+
+ - celery-worker
78+
+ topologyKey: "kubernetes.io/hostname"
79+
initContainers:
80+
```
81+
82+
Two new keys are needed for the anti-affinity:
83+
84+
- `weight` (range 1-100): The scheduler will prefer to schedule pods to nodes that satisfy the anti-affinity expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling anti-affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding "weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred. The weights of all of the matched WeightedPodAffinityTerm fields are added per-node to find the most preferred node(s)
85+
86+
- `podAffinityTerm`: Defines a set of pods that this pod should be not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key <topologyKey> matches that of any node on which a pod of the set of pods is running
87+
5688
More information and further examples can be found at:
5789

5890
<https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity>

0 commit comments

Comments
 (0)