Answers: <p><code>ResourceQuota</code> is</p>
  <blockquote>
  <p>the total amount of memory and CPU that can be used by all Containers running in a namespace</p>
  </blockquote>
  <p><code>LimitRange</code>is</p>
  <blockquote>
  <p>if ... the Container does not specify its own CPU limit, then the Container is assigned the default CPU limit</p>
  </blockquote>
  <ul>
  <li>Example of ResourceQuota:</li>
  </ul>
  <p>Imagine you have 2 namespaces in the same cluster, the namespace &quot;backup&quot; and namespace &quot;test&quot;. &quot;backup&quot; run critical pods and you want to guarantee that will always have enough resources (CPU and memory) to run it. So you can configure a ResourceQuota in the namespace &quot;test&quot; to use only a part of the total amount of CPU and memory in your cluster.</p>
  <p>Is like you say to k8s: &quot;The sum of all memory and CPU of all pods in the namespace &quot;test&quot; can't be higher than what is specified in the ResourceQuota, 20G for memory and 12 vCPU's&quot;</p>
  <ul>
  <li>Example of LimitRange:</li>
  </ul>
  <p>You can specify in the yaml the minimum and maximum amount of CPU and memory a container can consume but instead of configuring in every yaml file you can set a default value with LimitRange.</p>
  <p>Is like you say to k8s: &quot;If there is no resource configured in the yaml file apply this LimitRange.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-03-05T07:21:54.917Z
Answers: Limits set default constraints per container/resource. Does quota set the resource constraints per namespace, for all resources in the namespace? Even ones without a limit set?
Answers: nelaaro
Answers: CC BY-SA 4.0
Answers: 2021-03-04T15:33:12.817Z
Answers: 2021-03-04T15:33:12.817Z
Answers: Joao  Vitorino
Body: <p>I have been reading through <a href="https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/" rel="nofollow noreferrer">the docs</a> but it still is not clear as to why I should use one or the other. They have great examples of how to configure them but don't answer the why for quotes or limits very well.</p>
  <p>I want to understand</p>
  <pre><code>kind: ResourceQuota
  </code></pre>
  <p>and</p>
  <pre><code>kind: LimitRange
  </code></pre>
  <p>I am not so interested in the yaml this is very clearly given in the examples.
  I want to understand the use-cases better.</p>
  
Tags: <kubernetes><containers><deployment>
Title: kubernetes quota vs limit. What are they? How are they different? When should I use one or the other?
UserDisplayName: nelaaro
ThreadText: # kubernetes quota vs limit. What are they? How are they different? When should I use one or the other?
  
  (Asked by: username_0 on 2021-03-03)
  
  I have been reading through [the docs](https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/) but it still is not clear as to why I should use one or the other. They have great examples of how to configure them but don't answer the why for quotes or limits very well.
  
  I want to understand
  
  ```
  kind: ResourceQuota
  
  ```
  
  and
  
  ```
  kind: LimitRange
  
  ```
  
  I am not so interested in the yaml this is very clearly given in the examples.
  I want to understand the use-cases better.
  
  **Tags:** kubernetes, containers, deployment
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-03-04. Score: 3
  
  `ResourceQuota` is
  
  > the total amount of memory and CPU that can be used by all Containers running in a namespace
  
  `LimitRange`is
  
  > if ... the Container does not specify its own CPU limit, then the Container is assigned the default CPU limit
  
  * Example of ResourceQuota:
  
  Imagine you have 2 namespaces in the same cluster, the namespace "backup" and namespace "test". "backup" run critical pods and you want to guarantee that will always have enough resources (CPU and memory) to run it. So you can configure a ResourceQuota in the namespace "test" to use only a part of the total amount of CPU and memory in your cluster.
  
  Is like you say to k8s: "The sum of all memory and CPU of all pods in the namespace "test" can't be higher than what is specified in the ResourceQuota, 20G for memory and 12 vCPU's"
  
  * Example of LimitRange:
  
  You can specify in the yaml the minimum and maximum amount of CPU and memory a container can consume but instead of configuring in every yaml file you can set a default value with LimitRange.
  
  Is like you say to k8s: "If there is no resource configured in the yaml file apply this LimitRange.
  
  > **Comments:**
  > **username_0**: Limits set default constraints per container/resource. Does quota set the resource constraints per namespace, for all resources in the namespace? Even ones without a limit set?  
  
  ---
  
  