1

I need to restrict an app/deployment to run on specific cpus only (say 0-3 or just 1 or 2 etc.) I found out about CPU Manager and tried implement it with static policy but not able to achieve what I intend to.

I tried the following so far:

  1. Enabled cpu manager static policy on kubelet and verified that it is enabled
  2. Reserved the cpu with --reserved-cpus=0-3 option in the kubelet
  3. Ran a sample nginx deployment with limits equal to requests and cpu of integer value i.e. QoS of guaranteed is ensured and able to validate the cpu affinity with taskset -c -p $(pidof nginx)

So, this makes my nginx app to be restricted to run on all cpus other than reserved cpus (0-3), i.e. if my machine has 32 cpus, the app can run on any of the 4-31 cpus. And so can any other apps/deployments that will run. As I understand, the reserved cpus 0-3 will be reserved for system daemons, OS daemons etc.

My questions-

  1. Using the Kubernetes CPU Manager features, is it possible to pin certain cpu to an app/pod (in this case, my nginx app) to run on a specific cpu only (say 2 or 3 or 4-5)? If yes, how?
  2. If point number 1 is possible, can we perform the pinning at container level too i.e. say Pod A has two containers Container B and Container D. Is it possible to pin cpu 0-3 to Container B and cpu 4 to Container B?
  3. If none of this is possible using Kubernetes CPU Manager, what are the alternatives that are available at this point of time, if any?
Koshur
  • 378
  • 1
  • 6
  • 20
  • 1
    As I understand your question, you want to set up your dedicated number of CPU for each app/pod. As I've searched, I am only able to find some documentation that might help. https://kubevirt.io/user-guide/virtual_machines/dedicated_cpu_resources/ the other one is a Github topic I think this is a workaround to your problem. https://github.com/intel/CPU-Manager-for-Kubernetes – Bryan L Feb 21 '22 at 07:28
  • Great, I will explore this and get back. Is there anything in backlog to get this feature in native CPU Manager? – Koshur Feb 23 '22 at 13:30
  • If you mean by backlog is if they have an update for this feature in a native CPU manager , based on what I've read, in some articles there are no feature, but again this is only my understanding on what I've searched and read, I might haven't searched enough. – Bryan L Feb 24 '22 at 05:51

1 Answers1

0

As I understand your question, you want to set up your dedicated number of CPU for each app/pod. As I've searched.

I am only able to find some documentation that might help. The other one is a Github topic I think this is a workaround to your problem.

This is a disclaimer, based from what I've read, searched and understand there is no direct solution for this issue, only workarounds. I am still searching further for this.

Bryan L
  • 550
  • 1
  • 9