Resource Quota
Refer to the official Kubernetes documentation: Resource Quotas
TOC
Understanding Resource Requests & Limits
Used to restrict resources available to a specific namespace. The total resource usage by all Pods in the namespace (excluding those in a Terminating
state) must not exceed the quota.
Resource Requests: Define the minimum resources (e.g., CPU, memory) required by a container, guiding the Kubernetes Scheduler to place the Pod on a node with sufficient capacity.
Resource Limits: Define the maximum resources a container can consume, preventing resource exhaustion and ensuring cluster stability.
Quotas
Resource Quotas
If a resource is marked as Unlimited
, no explicit quota is enforced, but usage cannot exceed the cluster's available capacity.
Resource Quotas track the cumulative resource consumption (e.g., container limits, new Pods, or PVCs) within a namespace.
Supported Quota Types
Field | Description |
---|
Resource Requests | Total requested resources for all Pods in the namespace: |
Resource Limits | Total limit resources for all Pods in the namespace: |
Number of Pods | Maximum number of Pods allowed in the namespace. |
Note:
- Namespace quotas are derived from the project's allocated cluster resources. If any resource's available quota is 0, namespace creation will fail. Contact the administrator.
Unlimited
implies the namespace can consume the project's remaining cluster resources for that resource type.
YAML file example
# example-resourcequota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
name: example-resourcequota
namespace: <example>
spec:
hard:
limits.cpu: "20"
limits.memory: 20Gi
pods: "500"
requests.cpu: "2"
requests.memory: 2Gi
Create resouce quota by using CLI
Create via YAML file
kubectl apply -f example-resourcequota.yaml
Create via command line directly
kubectl create resourcequota example-resourcequota --namespace=<example> --hard=limits.cpu=20,limits.memory=20Gi,pods=500
Storage Quotas
Quota Type:
- All: Total PVC storage capacity in the namespace.
- Storage Class: Total PVC storage capacity for a specific storage class.
Note: Ensure the storage class is pre-assigned to the project containing the namespace.
Hardware accelerator Resources Quotas
Prerequisites
Procedure
Extended resource quotas are defined via ConfigMap. If the ConfigMap is missing, the resource category will not appear.
After you add your custom device configmap, Create resouce quota resouce like yaml below
YAML file example
# example-resourcequota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
name: example-resourcequota
namespace: <example>
spec:
hard:
requests.nvidia.com/gpu: "4" #this is your Hardware accelerator ConfigMap Resource Key
Other Quotas
The format for custom quota names must comply with the following specifications:
- If the custom quota name does not contain a slash (/): It must start and end with a letter or number, and can contain letters, numbers, hyphens (-), underscores (_), or periods (.), forming a qualified name with a maximum length of 63 characters.
- If the custom quota name contains a slash (/): The name is divided into two parts: prefix and name, in the form of: prefix/name. The prefix must be a valid DNS subdomain, while the name must comply with the rules for a qualified name.
- DNS Subdomain:
- Label: Must start and end with lowercase letters or numbers, may contain hyphens (-), but cannot be exclusively composed of hyphens, with a maximum length of 63 characters.
- Subdomain: Extends the rules of the label, allowing multiple labels to be connected by periods (.) to form a subdomain, with a maximum length of 253 characters.