John
John

Reputation: 55

EKS pod schedule according to the node CPU utilization

I am wondering if there is anyway to schedule pods according to the node CPU utilization. Most of our pods in eks are scheduled on single node even though rest of the nodes have lot of CPU left. Our cron-jobs are trying to spin up the new pods in that same node and failing to start because of the low CPU. I believe default kube scheduler should take care of this but it's not happening in our case.

So, Is there such an option as setting pod to schedule according to the CPU Utilization or if we can achieve this with scheduling strategies like node selector/affinity/resource requests&limits etc.,

Thanks in Advance!

Upvotes: 3

Views: 1277

Answers (1)

Fares
Fares

Reputation: 650

The scheduler relies on the CPU request set for the pod and not the CPU usage.

You need to set a CPU request that is high enough so that the scheduler knows that the node already containing a pod is not sufficient and will schedule it on another node that is able to host it.

EDIT:

If you absolutely want to spread your pods over your different nodes, you can use a topology-spread-constraint

topologySpreadConstraints: 
- maxSkew: 1 
   topologyKey: kubernetes.io/hostname 
   whenUnsatisfiable: ScheduleAnyway 
   labelSelector: 
     matchLabels:
       app: myApp

Note: with the ScheduleAnyway config, the scheduler will prioritise spreading the pods, and if not possible, it will schedule them anyways. You can also choose not to let him by setting DoNotSchedule

Upvotes: 2

Related Questions