Balance Pods in Kubernetes with Descheduler

Think of the Descheduler as Kubernetes DRS (Distributed Resource Scheduler) like VMware ESXi’s automatic rebalancing.

Kubernetes schedules pods only once when they are created but overtime this will become unbalanced and this becomes common when we drain the node so descheduler fixes gets Kubernetes the DRS sort of thing we see on our vCenter.

Add helm repo

helm repo add descheduler https://kubernetes-sigs.github.io/descheduler/

Update helm repo

helm repo update

Update helm repo

helm repo update

Install the Descheduler

Descheduler fits in kube-system namespace because it’s part of the cluster infrastructure, not a workload. Namespaces are only created when we want apps eg: rancher, monitoring stack,

helm install descheduler descheduler/descheduler--namespace kube-system --create-namespace

Get pods

kubectl get pods -A -n kube-system | grep desc*

Descheduler → automatically rebalances pods across all nodes so we need a cron schedule to do that

helm upgrade descheduler descheduler/descheduler --namespace kube-system --set schedule="*/5 * * * *"

Watch new pods appearing every 5 mins > – w flag is for watch

kubectl get pods -n kube-system -w | grep descheduler

As per this output, even 5 mins that schedule is working

Check the logs on the last pod to see what it did

kubectl logs -n kube-system descheduler-29582878-mgvfl

This now keeps all my pods evenly spread and can also automatically rebalances after reboots improving cluster stability

(Visited 2 times, 1 visits today)

By Ash Thomas

Ash Thomas is a seasoned IT professional with extensive experience as a technical expert, complemented by a keen interest in blockchain technology.