Namespaces provide an effective way to partition workspaces and divide cluster resources for different purposes. This topic explains how to create namespaces, set resource quotas, and configure limits in an ACS cluster.
Prerequisites
-
You have an ACS cluster.
-
You have obtained the cluster kubeconfig and connected to the cluster using kubectl.
Background
-
In an ACS cluster, you can use namespaces to create multiple virtual spaces. When a cluster is shared by many users, namespaces help you partition workspaces, divide cluster resources for different purposes, and allocate resources to each namespace by using resource quotas (ResourceQuota).
-
By default, running pods can dynamically allocate compute resources, such as CPU and memory, from the cluster based on their needs. Without proper resource quota management, a single pod might consume excessive resources, affecting the performance of other pods in the same cluster. To ensure fair and stable resource usage, set resource quotas for each namespace to limit resources like CPU, memory, and the number of pods. This facilitates effective isolation and fair scheduling for multiple users or workloads. For more information, see resource quotas.
Create a namespace
-
Log on to the ACS console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of the target cluster. In the left-side navigation pane, choose Namespaces and Quotas.
-
On the Namespace page, click Create. In the Create Namespace dialog box, enter a Name, configure Labels as needed, and then click OK.
Namespace labels identify the characteristics of a namespace. For example, you can use a label to mark a namespace for a testing environment. You can add multiple labels to a namespace.
Once created, the namespace appears in the namespace list.
Set resource quotas and limits
-
On the Namespace page, find the target namespace and click Resource Quotas and Limits in the Actions column.
-
In the Resource Quotas and Limits dialog box, set the resource quota (ResourceQuota) and limit range (LimitRange).
After you set a CPU or memory quota for a namespace, you must specify CPU or memory resource limits when you create a pod. Alternatively, you can configure a default limit range for the namespace to control the resource usage of containers. For more information, see resource quotas and Configure Default Memory Requests and Limits for a Namespace.
Related operations
After you create a namespace, you can perform the following operations on the Namespace page:
-
Modify namespace labels: In the Actions column for the target namespace, click Edit. In the Create Namespace dialog box, modify the namespace labels as needed, and click Confirm.
-
Delete a namespace: In the Actions column for the target namespace, click the
icon, and then click Delete. In the Confirm dialog box, click Confirm Deletion.Deleting a namespace also deletes all the resource objects within it.