HiveBrain v1.2.0
Get Started
← Back to all entries
principlekubernetesMinor

kubernetes quota vs limit. What are they? How are they different? When should I use one or the other?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
thewhatarekuberneteslimitotherdifferentonewhenhow

Problem

I have been reading through the docs 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.

Solution

ResourceQuota is

the total amount of memory and CPU that can be used by all Containers running in a namespace

LimitRangeis

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.

Context

StackExchange DevOps Q#13476, answer score: 3

Revisions (0)

No revisions yet.