# Setting a Resource Quota

Namespace-level resource quotas limit the amount of resources available to teams or users when these teams or users use the same cluster. The quotas include the total number of a type of objects and the total amount of compute resources (CPU and memory) consumed by the objects.

Quotas can be set only in clusters of v1.9 or later.

#### Prerequisites

- You have created a Kubernetes cluster. For details, see Creating a CCE Cluster.
- You have created a namespace. For details, see Creating a Namespace.

#### Usage

By default, running pods can use the CPUs and memory of a node without restrictions. This means the pods in a namespace may exhaust all resources of the cluster.

Kubernetes provides namespaces for you to group workloads in a cluster. By setting resource quotas for each namespace, you can prevent resource exhaustion and ensure cluster reliability.

You can configure quotas for resources such as CPU, memory, and the number of pods in a namespace. For more information, see Resource Quotas.

The following table recommends how many pods you can configure for your clusters of different sizes.

Cluster Scale | Recommended Number of Pods
--- | ---
50 nodes | 2,500 pods
200 nodes | 10,000 pods
1,000 nodes | 30,000 pods
2,000 nodes | 50,000 pods

Starting from clusters of v1.21 and later, the default Resource Quotas are created when a namespace is created. Table 1 lists the resource quotas based on cluster specifications. You can modify them according to your service requirements.

Table 1 Default resource quotas
Cluster Scale | Pod | Deployment | Secret | ConfigMap | Service
--- | --- | --- | --- | --- | ---
50 nodes | 2000 | 1000 | 1000 | 1000 | 1000
200 nodes | 2000 | 1000 | 1000 | 1000 | 1000
1,000 nodes | 5000 | 2000 | 2000 | 2000 | 2000
2,000 nodes | 5000 | 2000 | 2000 | 2000 | 2000

#### Procedure

1. Log in to the CCE console. In the navigation pane, choose Resource Management > Namespaces.
2. Select the cluster to which the namespace belongs from the Clusters drop-down list.
3. In the Operation column of a namespace, click Manage Quota.

   This operation cannot be performed on system namespaces kube-system and kube-public.

4. Set the resource quotas and click OK.

   - CPU (cores): maximum number of CPU cores that can be allocated to workload pods in the namespace.
   - Memory (MiB): maximum amount of memory that can be allocated to workload pods in the namespace.
   - StatefulSet: maximum number of StatefulSets that can be created in the namespace.
   - Deployment: maximum number of Deployments that can be created in the namespace.
   - Job: maximum number of one-off jobs that can be created in the namespace.
   - Cron Job: maximum number of cron jobs that can be created in the namespace.
   - Pod: maximum number of pods that can be created in the namespace.
   - Service: maximum number of Services that can be created in the namespace.
   - After setting CPU and memory quotas for a namespace, you must specify the request and limit values of CPU and memory resources when creating a workload. Otherwise, the workload cannot be created. If the quota of a resource is set to 0, the resource usage is not limited.
   - Accumulated quota usage includes the resources used by CCE to create default components, such as the Kubernetes Services (which can be viewed using kubectl) created under the default namespace. Therefore, you are advised to set a resource quota greater than expected to reserve resource for creating default components.

Parent topic: Namespaces