Skip to content

Commit fdc959d

Browse files
authored
docs: Added YAML file explanations for 'Pod Affinity and Anti-Affinity' section (#1467)
1 parent b414515 commit fdc959d

File tree

1 file changed

+12
-0
lines changed
  • website/docs/fundamentals/managed-node-groups/basics/affinity

1 file changed

+12
-0
lines changed

website/docs/fundamentals/managed-node-groups/basics/affinity/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ The following kustomization adds an `affinity` section to the **checkout** deplo
3939
modules/fundamentals/affinity/checkout/checkout.yaml
4040
Deployment/checkout
4141
```
42+
In the above manifest, the `podAffinity` section ensures:
43+
- Checkout pods will only be scheduled on nodes where Redis pods are running.
44+
- This is enforced by matching pods with label `app.kubernetes.io/component: redis`.
45+
- The `topologyKey: kubernetes.io/hostname` ensures this rule applies at the node level.
46+
47+
The `podAntiAffinity` section ensures:
48+
- Only one checkout pod runs per node.
49+
- This is achieved by preventing pods with labels `app.kubernetes.io/component: service` and `app.kubernetes.io/instance: checkout` from running on the same node.
4250

4351
To make the change, run the following command to modify the **checkout** deployment in your cluster:
4452

@@ -80,6 +88,10 @@ Next, we'll scale the `checkout-redis` to two instances for our two nodes, but f
8088
modules/fundamentals/affinity/checkout-redis/checkout-redis.yaml
8189
Deployment/checkout-redis
8290
```
91+
In the above manifest, the `podAntiAffinity` section ensures:
92+
- Redis pods are distributed across different nodes.
93+
- This is enforced by preventing multiple pods with label `app.kubernetes.io/component: redis` from running on the same node.
94+
- The `topologyKey: kubernetes.io/hostname` ensures this rule applies at the node level.
8395

8496
Apply it with the following command:
8597

0 commit comments

Comments
 (0)