Pod Anti Affinity
Create a nginx deployment with 3 pods
Add a ‘podAntiAffinity’ section to the deployment
The goal is to distribute all pod for this deployment across different nodes.
Use the affinity of this example to write the affinity section in the deployment.yaml file:
Note
The topologyKey value will be kubernetes.io/hostname because pod will not be on the same nodes.
-
Check that all pods are running on different nodes using:
kubectl get pods -o wide -
Scale the
Deploymentto five pods and try to understand what’s happening.