Score:0

How to limit service availability based on CPU usage?

us flag

My Pods are allocated 1000m CPU. I would like to make Pod not-Ready when CPU usage is over 900m or 90% of the allocated resources.

Is there a configuration for this or do I need to implement a check in my application that would signal readiness based on the CPU usage?

in flag
[`readinessProbe:` accepts a bunch of options](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#probe-v1-core) including (as sounds like your case) `exec:`; what have you already tried and what's it doing for you instead of un-Readying your Pod?
Gajus avatar
us flag
The question is whether there is a canonical way of doing it. I've written a few libraries that do this, like [Lightship](https://github.com/gajus/lightship). But implementing this in user land is error prone.
Gajus avatar
us flag
The reason I want to make the pod not-Ready when CPU is over 90% is because high congestion is causing the service to stop responding snappy. I would rather it become unavailable and use that signal to spin up more replicas.
in flag
There's for sure no canonical way, but I mentioned `exec` because I would expect if the pod is able to determine its own cpu usage (akin to `top` although certainly not _via_ `top`), or it was able to ask metrics-server about itself, then returning bogus from the pod's `exec` would de-Ready it
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.