Insufficient cpu in Kubernetes multi node cluster

12/11/2018

I am trying to deploy an application into my Kubernetes cluster. It is a multi node cluster. There are 3 m4.2xlrge aws instances.

m4.2xlarge
vCPU :- 8
Memory :- 32

Now, in my deployment.yaml file for that service, I have mentioned

limit:
  cpu: 11
request:
  cpu: 11

It is giving error, insufficient cpu and container is not scheduling. I have already (8*3)=24 CPU resources available and I requested for 11 CPU out of it. It should share the CPU resource across nodes. Is the limit and request CPU is applicable for the containers per node? That means, should I have atleast 11 CPU per aws instance?

-- Dinesh Ahuja
amazon-web-services
containers
cpu
docker
kubernetes

2 Answers

12/14/2018

When you specify a limit or request for a pod, it takes into account per node capacity of CPU or memory. In other words you can't have a Pod requesting more CPU or Memory which is available on a single worker node of your cluster, if you do it will go in Pending state and will not come up until it finds a node matching the request of the Pod.

In your case, worker node of size m4.2xlarge has 8 vCPUs, and in the deployment file you have requesed 11 vCPUs for the Pod. This will never work even though you have 3 nodes of size m4.2xlarge. A Pod always get scheduled on a single worker Node so it doesn't matter if the aggregate CPU capacity of your cluster is more than 11 vCPUs because a Pod will only be able to consume resources from a single worker node.

Hope this helps!

-- Samrat Priyadarshi
Source: StackOverflow

12/11/2018

A Pod is scheduled on a single Node. The resource requests: help decide where it can be scheduled. If you say requests: {cpu: 11} then there must be some single node with 11 (unreserved) cores available; but if your cluster only has 8-core m4.2xlarge nodes, no single node will be able to support this. Kubernetes can’t “aggregate” cores across nodes in any useful way at this level.

If you’re requesting a lot of CPU because your process has a lot of threads to do concurrent processing, consider turning the number of threads down (maybe even to just 1) but then changing the replicas: in a Deployment spec to run many copies of it. Each individual Pod will get scheduled on a single Node, but with many replicas you’ll get many Pods which can be spread across the three Nodes.

If your process really needs more than 8 cores to run, then you need individual systems with more than 8 cores; consider an m4.4xlarge (same RAM-to-CPU ratio) or a c4.4xlarge (same total RAM, twice the cores).

-- David Maze
Source: StackOverflow