<p>How to figure out how much min and max resources to allocate for each application deployment? I'm setting up a cluster and I haven't setup any resources and letting it run freely.</p>
<p>I guess I could use <code>top command</code> to figure out the load during the peak time and work on that but still top says like 6% or 10% but then I'm not sure how to calculate them to produce something like <code>0.5 cpu</code> or <code>100 MB</code>. Is there a method/formula to determine max and min based on <code>top command</code> usage?</p>
<p>I'm running two t3.medium nodes  and I have the following pods <code>httpd and tomcat in namespace1</code>, <code>mysql in namepsace2</code>, <code>jenkins and gitlab in namespace3</code>. Is there any guide to minimum resources it needs? or Do I have to figure it based on top or some other method?</p>

user630702
<p>There are few things to discuss here:</p>
<ol>
<li>Unix <code>top</code> and <code>kubectl top</code> are different:</li>
</ol>
<ul>
<li><p>Unix <code>top</code> uses <code>proc</code> virtual filesystem and reads <code>/proc/meminfo</code> file to get an actual information about the current memory usage.</p>
</li>
<li><p><code>kubectl top</code> shows metrics information based on reports from <a href="https://github.com/google/cadvisor" rel="nofollow noreferrer">cAdvisor</a>, which collects the resource usage. For example: <code>kubectl top pod POD_NAME --containers</code>: Show metrics for a given pod and its containers or <code>kubectl top node NODE_NAME</code>: Show metrics for a given node.</p>
</li>
</ul>
<ol start="2">
<li><p>You can use the <a href="https://github.com/kubernetes-sigs/metrics-server#kubernetes-metrics-server" rel="nofollow noreferrer">metrics-server</a> to get the CPU and memory usage of the pods. With it you will be able to <a href="https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/" rel="nofollow noreferrer">Assign CPU Resources to Containers and Pods</a>.</p>
</li>
<li><p>Optimally, your pods should be using exactly the amount of resources you requested but that's almost impossible to achieve. If the usage is lower than your request, you are wasting resources. If it's higher, you are risking performance issues. Consider a 25% margin up and down the request value as a good starting point. Regarding limits, achieving a good setting would depend on trying and adjusting. There is no optimal value that would fit everyone as it
depends on many factors related to the application itself, the
demand model, the tolerance to errors etc.</p>
</li>
<li><p>As a supplement I recommend going through the <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/" rel="nofollow noreferrer">Managing Resources for Containers</a> docs.</p>
</li>
</ol>
