Kubernetes "nice" a pod's CPU usage

5/30/2019

I have a cluster w/ 3 nodes. Hurray! The cluster doesn't autoscale nodes.

These nodes run an amazing web app, yet most of the time do almost nothing.

I also have a background process that could use an infinite amount of CPU (the usefulness drops rapidly but remains useful).

I want these background pods to run on each Node and slowed down to leave a 20% CPU headroom on the Node. Or similar.

That's the shape of a DaemonSet.

  • Can I tell Kubernetes to deprioritize the DaemonSet Pods w/ a 20% headroom?

  • Can the DaemonSet Pods detect the Nodes CPU usage and deprioritize themselves (risky if buggy)?

QoS looks like it's for scheduling and evicting pods to make room for other pods, but they don't get 'niced'.

Priority also looks like it's for eviction.

-- Michael Cole
kubernetes
kubernetes-pod

1 Answer

5/31/2019

You may achieve what you're looking for in many ways.

I imagine that you've already read this and that, based on the theory of this other.

Also RedHat has nice documentation about setting hardware limits via softwarre.

Here you can find how to restrict cpu usage, which may be set inside a container to achieve what you're looking for.

So, to recap: with K8S you can set requests and limits, and inside the container you can set even further restrictive limits.

Hope this gives you the solution or at least the path to follow in order to achieve what you want.

-- Matias Paglioni
Source: StackOverflow