How to make pod monopolize CPU kernel

When using docker, you can bind the container to a CPU kernel through the parameter cpuset

In this case, the number of context switches between CPUs by the operating system is greatly reduced, so the performance of applications in the container will be greatly improved.
In fact, cpuset is a common way to deploy online application type pods in production environment

To use functions similar to docker cpuset on kubernetes, the following two conditions need to be met
The QoS of the pod is guaranteed

Set requests and limits to the same value, such as 2

spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "2"
      requests:
        memory: "200Mi"
        cpu: "2"

In this way, the above pod will be bound to two exclusive CPU cores

Send a Message