<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=521127644762074&amp;ev=PageView&amp;noscript=1">

Action Item: Setting Kubernetes CPU Limits

Learn how Fairwinds Insights Action Items helps you set your CPU limits.


Hello everybody. Today, I'm going to talk about how to resolve the Insights Action Item CPU Limits should be set. We can see on the right side here that we have the Insights user interface, and it shows an action item that CPU limits should be set. I've clicked on this action item and now I see a bunch of metadata information, a description of the action item, as well as some links to documentation and some remediation instructions, which includes a code snippet.

We're going to walk through this real quick. So, we see here that I have a statefulset it's called argocd-redis-ha-server, and a container named redis, and the CPU limits are not set. What I'm going to do is find the code that created this object in Kubernetes. Anytime you have an object, it should have some YAML associated with it somewhere that deployed that object.

In my case, I have a directory on the left over here that has a whole bunch of YAML files in it. If we look at the statefulset, argocd-redis-ha-server, we can take a look at the containers in this particular statefulset. And we scroll down here and we see containers. It's a list. The first container in here is named redis. That's the one that our action item is referencing. So we look a little bit further. We see that there's no resources defined whatsoever for this container. So we can scroll down again in the action item description. And we see that we have some recommended YAML here. I'm going to go to the name redis, and I'm going to add a resources block, and I'm going to add a limits block. Underneath that, I'm going to say CPU, and I'm going to give it a value. We can start with 500 or a hundred milicores.

The next thing I'm going to do is actually take a look at how much CPU this particular workload is already using. I'm going to kubectl top pods in the argocd namespace. I'm going to look for redis-ha-server. And if we run that command and wait just a second, we will see that the argocd-redis-ha-server is currently using less than 10 milli cores. So I probably don't need to set my limit at 500 milicores, but just to be safe, I'm going to go ahead and set it to a hundred milicores. And over time I'm going to keep an eye on those resources and then maybe look at my Prometheus metrics report in Insights and see if that's a reasonable default to set.

Today we have resolved the action item CPU limits should be set by setting a CPU limit on the container referenced in this action item. Thanks for listening.