Skip to content

Instantly share code, notes, and snippets.

@hobbsh
Last active March 16, 2018 19:57
Show Gist options
  • Save hobbsh/e905e3b13b6bb109053c26a99f905228 to your computer and use it in GitHub Desktop.
Save hobbsh/e905e3b13b6bb109053c26a99f905228 to your computer and use it in GitHub Desktop.
Resource Quotas and Resource Limits Slides
<section data-background-transition='zoom' data-transition='concave' data-background='https://pixel.nymag.com/imgs/daily/vulture/2016/07/29/29-steve-brule-check-it-out.w710.h473.2x.jpg' data-state='blackout'>
<h2>Kubernetes Resource Quotas and Resource Limits</h2>
</br>
<h3>For your health</h3>
</section>
<section data-background-transition='zoom' data-transition='linear' id='try-it'>
<section data-transition='concave'>
<h2>Resource Limits vs Resource Quotas</h2>
<p>Memory and CPU constraints for a container are configured with resource requests and resource limits</p>
<p><b>Resource Quotas:</b> are resource limits that apply to a namespace</p>
</section>
<section>
<h2>Why are these things important?</h2>
<p>When Containers have resource requests specified, the scheduler can make better decisions about which nodes to place Pods on. And when Containers have their limits specified, contention for resources on a node can be handled in a specified manner.</p>
<p>When well configured resource quotas are set for a namespace, it is much harder for overall cluster resource contention to affect other namespaces</p>
</section>
<section data-transition='concave'>
<h2>Determining appropriate values</h2>
<img src="https://i.imgur.com/tovzLOL.png" width="80%"></img>
</section>
<section data-transition='concave'>
<h2>Setting resource quotas for your namespace</h2>
<pre><code>
Name: platform-rq
Namespace: platform
Resource Used Hard
-------- ---- ----
limits.cpu 1760m 2
limits.memory 1924Mi 2500M
requests.cpu 1120m 1500m
requests.memory 1275Mi 2G
</pre></code>
</section>
<section data-transition='concave'>
<h2>Setting resource limits in your deployments</h2>
<p>Because we use resource quotas, any container that does not have requests.cpu, requests.memory, limits.cpu, limits.memory will cause the pod to fail to deploy</p>
<pre><code>
resources:
limits:
cpu: "100m"
memory: "100Mi"
requests:
cpu: "55m"
memory: "75Mi"
</pre></code>
</section>
<section data-transition='concave'>
<h2>Avoid overcommitting</h2>
<p>This is a situation that we want to avoid if possible</p>
<pre><code>
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits
--------- ---- ------------ ---------- --------------- -------------
ingestion ingestion-service-6d549f7669-gvr4m 0 (0%) 0 (0%) 0 (0%) 0 (0%)
platform freshtracks-agent-744656f5d-7zdqf 510m (39%) 1010m (77%) 520Mi (18%) 1044Mi (36%)
platform freshtracks-node-exporter-9wxjv 0 (0%) 0 (0%) 0 (0%) 0 (0%)
platform heimdall-74b56cfb4c-mg8fr 120m (9%) 150m (11%) 135Mi (4%) 160Mi (5%)
platform p8s-prometheus-node-exporter-6prrq 0 (0%) 0 (0%) 0 (0%) 0 (0%)
platform tiller-deploy-5664745cb7-qp8c9 0 (0%) 0 (0%) 0 (0%) 0 (0%)
reporting token-service-786b7d9c4d-fftmh 250m (19%) 500m (38%) 64Mi (2%) 128Mi (4%)
waffleio-dev tiller-deploy-58c9d747cc-zpkzm 0 (0%) 0 (0%) 0 (0%) 0 (0%)
waffleio-production tiller-deploy-dc99644dc-bnxbk 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
CPU Requests CPU Limits Memory Requests Memory Limits
------------ ---------- --------------- -------------
880m (67%) 1660m (127%) 719Mi (25%) 1332Mi (46%)
</pre></code>
</section>
<section>
<h2>Pod eviction</h2>
<p>--kube-reserved and --evicition-threshold kubelet flags will evict pods from an overstuffed node in favor of preserving the kubelet</p>
</section>
<section data-transition='concave'>
<h2>Troubleshooting failed deploys</h2>
<p><code>kubectl get ev -n dana</code></p>
<p>Loggly</p>
<code>
syslog.host:*.dev "exceeded quota"
</code>
</section>
<section>
<h2>Tweaking your deployments for resource limits</h2>
<p>No limits - see error, set limits</p>
<p>Changing replicas</p>
<p>Changing max surge</p>
<p>Bump the quota</p>
</section>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment