How To Avoid Placement of More Than One Pod Replicas on Same Worker Node

Problem

  • How to avoid assignment of multiple replicas of a pod on a single worker node?
  • How to configure deployment to avoid co-location of replicas on a single node?

Environment

  • Platform9 Managed Kubernetes - All Versions
  • Kube-Scheduler

Procedure

  • PodAntiAffinity can be configured to ensure that the scheduler does not co-locate replicas on a single node.
  • Below mentioned is the snippet of PodAntiAffinity configured for a Nginx deployment with 3 pod replicas.
podAntiAffinity Configuration
Copy
  • This configuration makes sure that all 3 replicas of the pods are scheduled on three different nodes of the cluster.
kubectl output
Copy

Additional Information

Kubernetes Docs – Assigning Pods to Nodes

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard