<p>I have a cluster where I manage namespaces on a per project basis.</p>
<p>Each namespace is given a resource quotas object and DevOps define usage per deployment.</p>
<p>A recurrent issue I face is that Kubernetes schedule pods according to a very basic sum of &quot;used&quot; limits against the &quot;hard&quot; quotas.</p>
<p>I could be forced to set a fairly high amount, especially in CPU, as pods need to manage bursts, but very rarely more than a couple at the same time.</p>
<p>If I have a 10 pods application, each with the potential to burst to 4 core, I need to define a resource quotas limit of 40 core even though it's completely unrelated to the application potential usage, even under stress.</p>
<p>This is specifically true as most of these project need burst to handle pods startup.</p>
<p>VPA could have been an answer to that, but my main concern is pod startup and VPA needs to kill pods to adjust its resource usage, so it's a bit of a deadlock.</p>
<p>I'm not sure what the best practices are to manage resource usage in a k8s cluster.</p>
<p>Obviously, my approach is falling short.</p>

GabQ
<blockquote>
<p>If I have a <strong>10 pods</strong> application, each with the potential to burst to <strong>4</strong> core, I need to define a resource quotas limit of 40 cores even though it's completely unrelated to the application potential usage, even under stress.</p>
</blockquote>
<p>You don't need to define 40 cores.<br />
In K8S you can define minimum and maximum resources for your Objects.</p>
<p>For example, if you wish to limit the resources to a max of 4 CPU you can still start with 0.5 CPU which means that for 10 pods you will only need 0.5*10=5CPU</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: ...
spec:
  containers:
  - name: app
    image: ...
    #
    # Here we limit our Object regarding resources consuming
    # 
    resources:
      # Minimum resources for starting   
      requests:
        memory: &quot;64Mi&quot;
        # m= mili, in this sample it will require 0.5CPU
        cpu: &quot;500m&quot;
      
      # Maximum resources consumption
      limits:
        memory: &quot;128Mi&quot;
        cpu: &quot;4&quot;
</code></pre>
<p><a href="https://i.stack.imgur.com/2Cui7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2Cui7.png" alt="enter image description here" /></a></p>
<hr />
<p><a href="https://i.stack.imgur.com/bxse8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bxse8.jpg" alt="enter image description here" /></a></p>
