Managed Kubernetes
Latest
Frequently Asked Questions
Solutions
How Tos
Internal Only
Templates
Powered By

Title
Message
Create new category
What is the title of your new category?
Edit page index title
What is the title of the page index?
Edit category
What is the new title of your category?
Edit link
What is the new title and URL of your link?
How To Avoid Placement of More Than One Pod Replicas on Same Worker Node
Copy Markdown
Open in ChatGPT
Open in Claude
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
PodAntiAffinitycan be configured to ensure that the scheduler does not co-locate replicas on a single node.- Below mentioned is the snippet of
PodAntiAffinityconfigured for a Nginx deployment with 3 pod replicas.
podAntiAffinity Configuration
xxxxxxxxxx# kubectl get deployment nginx-deployment -o yaml | grep -w "podAntiAffinity:" -A8 podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: app operator: In values: - nginx topologyKey: kubernetes.io/hostname- This configuration makes sure that all 3 replicas of the pods are scheduled on three different nodes of the cluster.
kubectl output
xxxxxxxxxx# kubectl get po -o wide -n defaultNAME READY STATUS RESTARTS AGE IP NODE nginx-deployment-84c6674589-cxp55 1/1 Running 0 55s 10.20.152.138 10.128.228.29 nginx-deployment-84c6674589-hzmnn 1/1 Running 0 55s 10.20.155.70 10.128.228.28 nginx-deployment-84c6674589-vq4l2 1/1 Running 0 55s 10.20.225.7 10.128.226.44Additional Information
VariableType to search · ESC to discard
GlossaryType to search · ESC to discard
InsertType to search · ESC to discard
No matches
Last updated on
Was this page helpful?
Discard Changes
Do you want to discard your current changes and overwrite with the template?
Archive Synced Block
Message
Create new Template
What is this template's title?
Delete Template
Message