Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Kubernetes, what is the difference between ResourceQuota vs LimitRange objects

Tags:

Please explain the difference between ResourceQuota vs LimitRange objects in Kubernetes...?

like image 372
Hafiz Avatar asked Feb 28 '19 16:02

Hafiz


People also ask

What is ResourceQuota in Kubernetes?

A resource quota, defined by a ResourceQuota object, provides constraints that limit aggregate resource consumption per namespace. It can limit the quantity of objects that can be created in a namespace by type, as well as the total amount of compute resources that may be consumed by resources in that namespace.

What is LimitRange?

A LimitRange provides constraints that can: Enforce minimum and maximum compute resources usage per Pod or Container in a namespace. Enforce minimum and maximum storage request per PersistentVolumeClaim in a namespace. Enforce a ratio between request and limit for a resource in a namespace.

How many pods does namespace Kubernetes have?

More specifically, Kubernetes is designed to accommodate configurations that meet all of the following criteria: No more than 110 pods per node. No more than 5000 nodes. No more than 150000 total pods.

What is request and limit in Kubernetes?

Requests and LimitsRequests are what the container is guaranteed to get. If a container requests a resource, Kubernetes will only schedule it on a node that can give it that resource. Limits, on the other hand, make sure a container never goes above a certain value.


1 Answers

LimitRange and ResourceQuota are objects used to control resource usage by a Kubernetes cluster administrator.

ResourceQuota is for limiting the total resource consumption of a namespace, for example:

apiVersion: v1 kind: ResourceQuota metadata:   name: object-counts spec:   hard:     configmaps: "10"      persistentvolumeclaims: "4"      replicationcontrollers: "20"      secrets: "10"      services: "10" 

LimitRangeis for managing constraints at a pod and container level within the project.

apiVersion: "v1" kind: "LimitRange" metadata:   name: "resource-limits"  spec:   limits:     -       type: "Pod"       max:         cpu: "2"          memory: "1Gi"        min:         cpu: "200m"          memory: "6Mi"      -       type: "Container"       max:         cpu: "2"          memory: "1Gi"        min:         cpu: "100m"          memory: "4Mi"        default:         cpu: "300m"          memory: "200Mi"        defaultRequest:         cpu: "200m"          memory: "100Mi"        maxLimitRequestRatio:         cpu: "10"  

An individual Pod or Container that requests resources outside of these LimitRange constraints will be rejected, whereas a ResourceQuota only applies to all of the namespace/project's objects in aggregate.

like image 119
P Ackerman Avatar answered Oct 26 '22 22:10

P Ackerman