You can create namespaces on a master instance and use the namespaces to classify cluster resources. You can also configure resource quotas for namespaces. Each resource quota includes a CPU limit and a memory limit. This topic describes how to manage namespaces and resource quotas.

Background information

  • You can use kubectl to manage namespaces and resource quotas on a master instance. After you create a namespace on a master instance, a similar namespace is automatically created in each cluster that is associated with the master instance. The namespace on the master instance is synchronized to the same namespace in each cluster.
  • A master instance administrator can specify the priorities of the namespaces that are created on a master instance. Jobs in different namespaces are scheduled based on the priorities of the namespaces. A master instance submits jobs to a queue based on the priorities of the namespaces to which the jobs belong.
  • A master instance administrator can configure resource quotas for the namespaces that are created on a master instance. The master instance schedules jobs based on the CPU and memory limits in the resource quota of the namespace to which the jobs belong. If the resource request of a job exceeds one of the limits, the master instance hangs the job. The job is not submitted to the queue.
Note Master instance administrators are the creators of master instances. A master instance administrator can create namespaces for accounts that are assigned the developer role, specify the priorities of the namespaces, and configure resource quotas for the namespaces. Only after a master instance administrator creates a namespace for a developer account, the developer account can be used to create jobs in the namespace.

Step 1: Create a namespace

  1. Log on to the ACK One Console. In the left-side navigation, choose Distributed Cloud Architecture > Multi-cluster Management.
  2. On the Multi-cluster Management page, click Master Instance Basic Information, view and obtain the KubeConfig of the master instance under the page. Then, use kubectl to access the master instance.
  3. Run the following command to create a namespace.
    Replace <your-namespace> with the name of the namespace that you want to create.
    kubectl create namespace <your-namespace>

Step 2: Specify the priority of the namespace

Run the following command to specify the priority of the namespace.
  • Replace <your-namespace> with the name of the namespace that you created.
  • Replace <your-priority> with a priority value that ranges from 0 to 9999. A greater value indicates a higher priority.
kubectl annotate namespace <your-namespace> ack-mc-priority=<your-priority>

Step 3: Manage the resource quota of the namespace

Modify the default resource quota of the namespace

When a master instance creates a namespace, the instance automatically configures a default resource quota named ack-mc-default-resourcequota for the namespace. The default resource quota includes a CPU limit and a memory limit. The CPU limit is set to 10 and the memory limit is set to 10 GiB. You can run the following command to modify the CPU and memory limits in the default resource quota.

Replace <your-namespace> with the name of the namespace whose default resource quota you want to modify.

kubectl edit resourcequota ack-mc-default-resourcequota -n <your-namespace>

Configure a resource quota for the namespace

  1. Run the following command to configure a resource quota for the namespace.
    • Replace <your-name> with the name of the resource quota that you want to configure.
    • Replace <your-namespace> with the name of the namespace for which you want to configure the resource quota.
    • Replace <your-cpu-quota> with a CPU limit value, such as 10.
    • Replace <your-memory-quota> with a memory limit value, such as 10 GiB.
    cat << EOF | kubectl apply -f -
    apiVersion: v1
    kind: ResourceQuota
    metadata:
      name: <your-name>
      namespace: <your-namespace>
    spec:
      hard:
        cpu: <your-cpu-quota>
        memory: <your-memory-quota>
    EOF
  2. Run the following command to delete the default resource quota.
    Note After you configure a resource quota for a namespace, delete the default resource quota of the namespace.
    kubectl delete resourcequota ack-mc-default-resourcequota -n <your-namespace>