1"use strict";(self.webpackChunkmia_platform_docs=self.webpackChunkmia_platform_docs||[]).push([["17180"],{869905(e,n,s){s.r(n),s.d(n,{metadata:()=>o,default:()=>u,frontMatter:()=>i,contentTitle:()=>a,toc:()=>c,assets:()=>l});var o=JSON.parse('{"id":"requirements/installation-guidelines/console/self-hosted/ranges-and-quotas","title":"Configure Limit Ranges and Resource Quotas","description":"Background","source":"@site/versioned_docs/version-15.0.1/requirements/installation-guidelines/console/self-hosted/ranges-and-quotas.md","sourceDirName":"requirements/installation-guidelines/console/self-hosted","slug":"/requirements/installation-guidelines/console/self-hosted/ranges-and-quotas","permalink":"/docs/15.0.1/requirements/installation-guidelines/console/self-hosted/ranges-and-quotas","draft":false,"unlisted":false,"tags":[],"version":"15.0.1","frontMatter":{"id":"ranges-and-quotas","title":"Configure Limit Ranges and Resource Quotas","sidebar_label":"Configure Limit Ranges and Resource Quotas"},"sidebar":"governance","previous":{"title":"Private clusters","permalink":"/docs/15.0.1/requirements/installation-guidelines/console/self-hosted/private-clusters"},"next":{"title":"Deployment tools","permalink":"/docs/15.0.1/requirements/installation-guidelines/console/self-hosted/third-party-integrations/deployment-tools"}}'),t=s(474848),r=s(28453);let i={id:"ranges-and-quotas",title:"Configure Limit Ranges and Resource Quotas",sidebar_label:"Configure Limit Ranges and Resource Quotas"},a,l={},c=[{value:"Background",id:"background",level:2},{value:"What are Limit Ranges?",id:"what-are-limit-ranges",level:3},{value:"What are Resource Quotas?",id:"what-are-resource-quotas",level:3},{value:"How to choose ranges and quotas",id:"how-to-choose-ranges-and-quotas",level:2},{value:"Limit Ranges",id:"limit-ranges",level:3},{value:"Resource Quotas",id:"resource-quotas",level:3}];function d(e){let n={a:"a",admonition:"admonition",code:"code",em:"em",h2:"h2",h3:"h3",hr:"hr",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",section:"section",strong:"strong",sup:"sup",ul:"ul",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h2,{id:"background",children:"Backgroun
1d"}),"\n",(0,t.jsx)(n.h3,{id:"what-are-limit-ranges",children:"What are Limit Ranges?"}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Limit Ranges"})," are Kubernetes objects defined at ",(0,t.jsx)(n.strong,{children:"namespace level"}),", that can be leveraged to simplify resource control over Containers and Pods.\nBesides restricting resource allocation, they provide the possibility to define ",(0,t.jsx)(n.strong,{children:"default values"})," for ",(0,t.jsx)(n.strong,{children:"CPU/Memory"})," ",(0,t.jsx)(n.code,{children:"requests"})," and ",(0,t.jsx)(n.code,{children:"limits"}),", to be applied to all the Containers whose ",(0,t.jsx)(n.code,{children:"resources"})," field was left undefined."]}),"\n",(0,t.jsxs)(n.p,{children:["Click ",(0,t.jsx)(n.a,{href:"https://kubernetes.io/docs/concepts/policy/limit-range/",children:"here"})," to read the official documentation about Limit Ranges."]}),"\n",(0,t.jsx)(n.h3,{id:"what-are-resource-quotas",children:"What are Resource Quotas?"}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Resource Quotas"})," are a Kubernetes tool to constrain aggregate resource consumption per ",(0,t.jsx)(n.strong,{children:"namespace"}),".\nTheir main purpose is to assign a portion of resources to each namespace, thus preventing environments from consuming more than their fair share."]}),"\n",(0,t.jsxs)(n.p,{children:["Click ",(0,t.jsx)(n.a,{href:"https://kubernetes.io/docs/concepts/policy/resource-quotas/",children:"here"})," to read the official documentation about Resource Quotas."]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"Visual representation of Limit Ranges and Resource Quotas",src:s(14503).A+"",width:"974",height:"691"})}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h2,{id:"how-to-choose-ranges-and-quotas",children:"How to choose ranges and quotas"}),"\n",(0,t.jsx)(n.p,{children:"When creating a new project, default configurations of both Limit Ranges and Resource Quotas are provided.\nThe values chosen for the default objects were selected after running analysis over existing environments."}),"\n",(0,t.jsx)(n.h3,{id:"limit-ranges",children:"Limit Ranges"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-YAML",children:"apiVersion: v1\nkind: LimitRange\nmetadata:\n name: default-limit-range\nspec:\n limits:\n - default:\n memory: 300Mi\n cpu: 300m\n defaultRequest:\n memory: 150Mi\n cpu: 100m\n type: Container\n"})}),"\n",(0,t.jsxs)(n.p,{children:["The snippet above shows the default ",(0,t.jsx)(n.code,{children:"LimitRange"})," configuration. Requests and limits are slightly above the average resources needed by Containers in our environments, thus they should be enough for any new Container.\nNevertheless, they may happen to be significantly higher than the resources needed by your services, and you may end up ",(0,t.jsx)(n.strong,{children:"wasting resources"}),".\nThus, it is ",(0,t.jsx)(n.strong,{children:"highly recommended"})," to define proper ",(0,t.jsx)(n.code,{children:"requests"})," and ",(0,t.jsx)(n.code,{children:"limits"})," for each Container included in every Pod and tune your ",(0,t.jsx)(n.code,{children:"LimitRange"})," accordingly."]}),"\n",(0,t.jsx)(n.admonition,{type:"info",children:(0,t.jsxs)(n.p,{children:["You can follow ",(0,t.jsx)(n.a,{href:"/docs/15.0.1/products/console/tutorials/set-requests-limits-of-a-microservice",children:"this tutorial"})," on how to set ",(0,t.jsx)(n.code,{children:"requests"})," and ",(0,t.jsx)(n.code,{children:"limits"})," of a microservice, and leverage the results to find more suitable defaults for your custom ",(0,t.jsx)(n.code,{children:"LimitRange"}),"."]})}),"\n",(0,t.jsx)(n.h3,{id:"resource-quotas",children:"Resource Quotas"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-YAML",children:'apiVersion: v1\nkind: ResourceQuota\nmetadata:\n name: default-resource-quota\nspec:\n hard:\n requests:\n cpu: "1"\n memory: 1Gi\n limits:\n cpu: "3"\n memory: 2Gi\n'})}),"\n",(0,t.jsxs)(n.p,{children:["The default ",(0,t.jsx)(n.code,{children:"ResourceQuota"})," configuration file is illustrated above. Although they are still the result of analysis over existing environments, in this case the default values are ",(0,t.jsx)(n.strong,{children:"very strict"})," and may not be suitable for your namespace.\nThe reason behind this choice is to ",(0,t.jsx)(n.strong,{children:"encourage tuning the values"})," according to the environment needs."]}),"\n",(0,t.jsx)(n.admonition,{type:"warning",children:(0,t.jsxs)(n.p,{children:["Not setting the ",(0,t.jsx)(n.code,{children:"ResourceQuota"})," specs to proper values may lead to errors and slowdowns. Use the defaults at your own risk!"]})}),"\n",(0,t.jsx)(n.p,{children:"There are no best practices on how to tune Resource Quotas. There may be multiple suitable policies for a project, depending on how many resources were assigned to the project, how many and which environments it requires, and so on."}),"\n",(0,t.jsxs)(n.p,{children:["An example",(0,t.jsx)(n.sup,{children:(0,t.jsx)(n.a,{href:"#user-content-fn-1",id:"user-content-fnref-1","data-footnote-ref":!0,"aria-describedby":"footnote-label",children:"1"})})," may be a project that was assigned 32GiB RAM and 16 cores of a multitenant cluster. Let's say this project needs 3 environments: ",(0,t.jsx)(n.strong,{children:"development"}),", ",(0,t.jsx)(n.strong,{children:"preproduction"}),", and ",(0,t.jsx)(n.strong,{children:"production"}),".\nA possible policy would be:"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["18GiB RAM and 8 cores for the ",(0,t.jsx)(n.strong,{children:"production"})," environment, to constrain it as little as possible;"]}),"\n",(0,t.jsxs)(n.li,{children:["10GiB RAM and 4 cores for the ",(0,t.jsx)(n.strong,{children:"preproduction"})," environment;"]}),"\n",(0,t.jsxs)(n.li,{children:["2GiB RAM and 2 cores for the ",(0,t.jsx)(n.strong,{children:"development"})," environment (assuming it is just for testing purposes);"]}),"\n",(0,t.jsx)(n.li,{children:"2GiB RAM and 2 cores in reserve for future allocation."}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["As shown in the example above, it is ",(0,t.jsx)(n.strong,{children:"highly recommended"})," to define different quotas depending on the environment.\nThis way, you can ensure proper distribution of resources among all the namespaces of the project, while avoiding provisioning issues."]}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsxs)(n.p,{children:["For the time being, to edit your ",(0,t.jsx)(n.code,{children:"LimitRange"})," and ",(0,t.jsx)(n.code,{children:"ResourceQuota"}),", you will need to access the files in the ",(0,t.jsx)(n.em,{children:"Configurations"})," repository of your project.\nThe defaults are located in each environment directory, inside the ",(0,t.jsx)(n.code,{children:"configurations"})," folder."]}
1),"\n",(0,t.jsx)(n.admonition,{type:"caution",children:(0,t.jsxs)(n.p,{children:["To avoid errors, remember to tune the values ",(0,t.jsx)(n.strong,{children:"BEFORE"})," releasing the project."]})}),"\n","\n",(0,t.jsxs)(n.section,{"data-footnotes":!0,className:"footnotes",children:[(0,t.jsx)(n.h2,{className:"sr-only",id:"footnote-label",children:"Footnotes"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{id:"user-content-fn-1",children:["\n",(0,t.jsxs)(n.p,{children:["Adapted from the Kubernetes documentation (link ",(0,t.jsx)(n.a,{href:"https://kubernetes.io/docs/concepts/policy/resource-quotas/",children:"here"}),"). ",(0,t.jsx)(n.a,{href:"#user-content-fnref-1","data-footnote-backref":"","aria-label":"Back to reference 1",className:"data-footnote-backref",children:"\u21A9"})]}),"\n"]}),"\n"]}),"\n"]})]})}function u(e={}){let{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},14503(e,n,s){s.d(n,{A:()=>o});let o=s.p+"assets/images/ranges-and-quotas-c065cd53ab49c903b544593b7c572c8d.png"},28453(e,n,s){s.d(n,{R:()=>i,x:()=>a});var o=s(296540);let t={},r=o.createContext(t);function i(e){let n=o.useContext(r);return o.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),o.createElement(r.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.