Resource Quota

Resource quotas are mechanisms created to constrain the usage of resources by users. This process operates as follows:

  • Resource Quotas apply to Namespaces and each Namespace can have a maximum of one ResourceQuota object.

  • Once the computational resources quota has been initiated, computational resource requests or limits must be configured when creating the container (default values can also be set using the LimitRange function).

  • New resources cannot be created if the user exceeds their quota.

Activating Resource Quota Function

  • Firstly, configure admittance control --admission-control=ResourceQuota when launching API Server.

  • Secondly, create a ResourceQuota object in the namespace.

Types of Resource Quotas

  • Computational resources, including CPU and memory

    • CPU, limits.cpu, requests.cpu

    • Memory, limits.memory, requests.memory

  • Storage resources, including total storage and specific storage class total

    • Requests.storage: total storage resources, such as 500Gi

    • Persistentvolumeclaims: pvc number

    • .storageclass.storage.k8s.io/requests.storage

    • .storageclass.storage.k8s.io/persistentvolumeclaims

    • Requests.ephemeral-storage and limits.ephemeral-storage (requires v1.8+)

  • Object count, meaning the number of creatable objects

    • Pods, replicationcontrollers, configmaps, secrets

    • Resourcequotas, persistentvolumeclaims

    • Services, services.loadbalancers, services.nodeports

Computational resource example:

Object count example:

LimitRange

By default, no CPU or memory limits exist for any container in Kubernetes. LimitRange is used to add a resource limit to the Namespace, consisting of minimum, maximum, and default resources. For example,

Quota Ranges

Several ranges can be specified when creating each quota

Scope
Description

Terminating

Pod with podSpec.ActiveDeadlineSeconds>=0

NotTerminating

Pod with podSpec.activeDeadlineSeconds=nil

BestEffort

Pod where all containers' requests and limits are not set (Best-Effort)

NotBestEffort

Opposite of BestEffort

最后更新于