Scheduling application replicas to different nodes (pod affinity)
Using nodeAffinity
does not ensure that pods will next time be scheduled onto separate nodes, and for real application high availability, the best practice is to ensure that application pods are scheduled onto separate nodes. If one of the nodes is down/rebooted/replaced, having all the pods running on that node will cause the application to go down and its services to be unavailable.
Let's update the deployment.yaml
file with the podAntiAffinity
rule so that the nginx
application is only scheduled to gke-kubectl-lab-we-app-pool
and onto separate nodes:
... spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: node...