Skip to content

Managing and accessing resource quotas and limits

In the Kubernetes ecosystem, resource may represent different things:

  • A Kubernetes "object" is oftentimes referred to as a "resource" (such as a Pod or Secret).
  • Compute resources are also "resources" consumed by applications deployed of Kubernetes resources.

This documentation refers to "Compute resources" consumed by "Kubernetes resources".

Rectricted resouce usage

As nothing comes free and, for a smoothly running cluster, fair use of its resources is in order.
On the WoK platformn, resource usage is regulated by several mechanisms:

  • Global resource usage at the project/namespace level is limited by resourceQuotas
  • Resource usage at the Kubernetes object scope may be limited by LimitRanges

Moreover, the distinction is made between resources requested at the scheduling time (a.k.a. "requests") and resources actually consumed at run time (a.k.a. "limits"). While the former only dictates how the cluster scheduler will react upon receiving resource creation requests, the latter may interfere with the lifecycle of a Kubernetes resource.

Displaying resource quotas

Quotas are defined by the ResourceQuotas, a kind of Kubernetes resources that are defined by the cluster administrators. Users may request for quota extension through their usual support channel.

To list ResourceQuotas in your project, type the following command:

$ oc get resourcequotas
NAME                    AGE    REQUEST                                    LIMIT
test-mkdocs-qs1-quota   178d   configmaps: 2/100, [...], services: 0/10   limits.memory: 0/2Gi

$ oc describe resourcequota test-mkdocs-qs1-quota
Name:                                                       test-mkdocs-qs1-quota
Namespace:                                                  test-mkdocs-qs1
Resource                                                    Used  Hard
--------                                                    ----  ----
configmaps                                                  2     100
csi-cephfs-sc.storageclass.storage.k8s.io/requests.storage  0     50Gi
csi-rbd-sc.storageclass.storage.k8s.io/requests.storage     0     50Gi
limits.memory                                               0     2Gi
openshift.io/imagestreams                                   0     20
persistentvolumeclaims                                      0     20
pods                                                        0     10
requests.cpu                                                0     4
requests.memory                                             0     2Gi
requests.storage                                            0     50Gi
secrets                                                     6     100
services                                                    0     10

Multiple ResourceQuotas may be defined in a project, each one may target different or similar resources, resources may be scoped and if several ResourceQuotas target the exact same objects, the most restrictive is enforced.

Note

A graphical representation of the quota and its use, with gauge counters, is available through the Project tab in the Developer view of the WebGUI.

Displaying limit ranges

Limit ranges for resource usage at the Kubernetes resource level is defined by LimitRanges, another kind of Kubernetes resources that are defned by the cluster administrators. Users may request for limit ranges adjustments through their usual support channel.

To list LimitRanges in your project, type the following command:

$ oc get limitranges
NAME                     CREATED AT
test-mkdocs-qs1-limits   2023-07-24T16:17:15Z

$ oc describe limitrange test-mkdocs-qs1-limits
Name:       test-mkdocs-qs1-limits
Namespace:  test-mkdocs-qs1
Type        Resource  Min  Max  Default Request  Default Limit  Max Limit/Request Ratio
----        --------  ---  ---  ---------------  -------------  -----------------------
Container   memory    8Mi  2Gi  128Mi            128Mi          -
Container   cpu       -    -    100m             -              -
Pod         memory    8Mi  2Gi  -                -              -

LimitRanges will also set a resource request and/or value by default, upon corresponding resource creation, if it is not set by the resource definition used. For instance, in this project when deployments define pods and containers, if the deployment does not set cpu or memory requests, the default value will be used instead.
This is both a watchdog and a convenience for the user.