Is there a way to force the use of the same physical CPU while allocating cores to a pod in Kubernetes?

8/18/2020

I was wondering if it was possible to force Kubernetes to allocate the cores from the same CPU while spinning up a POD. What I would like Kubernetes to do is, as new PODs are created, the cores allocated to them should come from -let's say- CPU1 as long as there are cores still available on it. CPU2's, CPU3's, etc. cores should not be used in the newly initiated pod. I would like my PODs to have cores allocated from a single CPU as long as it is possible.

Is there a way to achieve this?

Also, is there a way to see from which physical CPUs the cores(cpu) of a POD is coming from?

Thanks a lot.

Edit: Let me explain why I want to do this.

We are running a Spark cluster on Kubernetes. The lead of system/linux administration team warned us about the concept of NUMA. He told us that we could improve the performance of our executor pods if we were to allocate the cores from the same physical CPU. That is why I started digging into this.

I found this Kubernetes CPU Manager. The documentation says:

CPU Manager allocates CPUs in a topological order on a best-effort basis. If a whole socket is free, the CPU Manager will exclusively allocate the CPUs from the free socket to the workload. This boosts the performance of the workload by avoiding any cross-socket traffic.

enter image description here

Also on the same page:

Allocate all the logical CPUs (hyperthreads) from the same physical CPU core if available and the container requests an entire core worth of CPUs.

enter image description here

So now I am starting to think maybe what I need is to enable the static policy for the CPU manager to get what I want.

-- honor
kubernetes
kubernetes-pod

0 Answers