<p>Automating this kind of behaviour is a quite risky since you have ResourceQuotas usually set up as a constraint for a namespace and from there on the pods must be aligned with it. 
You might end up with a pod non being scheduled at all.</p>

CC BY-SA 4.0
2020-03-08T20:32:14.143Z
2020-03-08T20:32:14.143Z
Recoba20
<p>Great question, especially mentioning fine-tuning on DEV / STG during performance testing. You may try using <a href="https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler" rel="nofollow noreferrer">Vertical Pod Autoscaler</a> to at least get good baseline and go from there.</p>
<p>You can just use the <code>recommender</code> component (<code>spec.updatePolicy.updateMode: Off</code>) and not touch controllers at all:</p>
<blockquote>
<p>Recommender - it monitors the current and past resource consumption and, based on it, provides recommended values for the containers' cpu and memory requests.</p>
</blockquote>
<hr />
<p>Keep in mind that VPA can not work with HPA enabled, and also keep in mind that each &quot;adjustment&quot; causes new ReplicaSet to be created (more limitations are <a href="https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler#known-limitations" rel="nofollow noreferrer">documented in the docs</a>).</p>

CC BY-SA 4.0
2023-06-24T13:30:41.347Z
2023-06-24T13:30:41.347Z
Kyslik
<p>I know of ways to set up monitoring (e.g. prometheus/alert-manger) to notify me if kubernetes pod requests/limits are too far off actual container usage.</p>

<p>Are there any systems built to help you actually act on this information in some automated fashion though?  This may sound odd as I realize automatically raising a limit makes it... not a limit?</p>

<p>Having said that, it still sounds useful to be able to automate tuning across a large k8s environment.  This may be especially true during non-prod/staging when you're doing load testing and trying to figure out what the reasonable limits are in the first place.</p>

<kubernetes>
Auto tune kubernetes requests/limits?
John Humphreys
# Auto tune kubernetes requests/limits?

(Asked by: username_0 on 2020-03-08)

I know of ways to set up monitoring (e.g. prometheus/alert-manger) to notify me if kubernetes pod requests/limits are too far off actual container usage.

Are there any systems built to help you actually act on this information in some automated fashion though? This may sound odd as I realize automatically raising a limit makes it... not a limit?

Having said that, it still sounds useful to be able to automate tuning across a large k8s environment. This may be especially true during non-prod/staging when you're doing load testing and trying to figure out what the reasonable limits are in the first place.

**Tags:** kubernetes


---

## 2 answers

### Answer by username_1 on 2020-03-08. Score: 1

Automating this kind of behaviour is a quite risky since you have ResourceQuotas usually set up as a constraint for a namespace and from there on the pods must be aligned with it.
You might end up with a pod non being scheduled at all.


---

### Answer by username_2 on 2023-06-24. Score: 0

Great question, especially mentioning fine-tuning on DEV / STG during performance testing. You may try using [Vertical Pod Autoscaler](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler) to at least get good baseline and go from there.

You can just use the `recommender` component (`spec.updatePolicy.updateMode: Off`) and not touch controllers at all:

> Recommender - it monitors the current and past resource consumption and, based on it, provides recommended values for the containers' cpu and memory requests.

---

Keep in mind that VPA can not work with HPA enabled, and also keep in mind that each "adjustment" causes new ReplicaSet to be created (more limitations are [documented in the docs](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler#known-limitations)).


---

