All Products
Search
Document Center

Container Service for Kubernetes:CPU Suppress

Last Updated:May 16, 2024

The ack-koordinator component provides the CPU Suppress feature. You can use this feature to limit the CPU usage of BestEffort (BE) pods on a node. This topic describes how to use the CPU Suppress feature provided by ack-koordinator.

Background Information

In the dynamic resource overcommitment model that is provided by ack-koordinator, the total amount of reclaimed resources dynamically changes based on the actual amount of resources used by latency-sensitive (LS) pods. Reclaimed resources can be used by BE pods. You can use the dynamic resource overcommitment feature to improve the resource utilization of a cluster by deploying both LS pods and BE pods in the cluster. To ensure sufficient CPU resources for LS pods on a node, you can use ack-koordinator to limit the CPU usage of the BE pods on the node. The CPU Suppress feature can maintain the resource utilization of a node below the specified threshold and limit the amount of CPU resources that can be used by BE pods. This ensures the stability of the containers on the node. The CPU Suppress feature can limit the amount of CPU resources that can be used by BE pods when the overall resource usage of the node is below the threshold. This ensures that the containers on the node have sufficient resources to run stably.

In the following figure, CPU Threshold indicates the CPU usage threshold of a node. Pod (LS).Usage indicates the CPU usage of LS pods. CPU Restriction for BE indicates the CPU usage of BE pods. The amount of CPU resources that can be used by BE pods is adjusted based on the fluctuation of the CPU usage of LS pods. We recommend that you use the same value for CPU Threshold and the reserved CPU watermark in the dynamic resource overcommitment model. This ensures a consistent level of CPU resource utilization.

image

Prerequisites

ack-koordinator 0.4.0 or later is installed. For more information about how to install ack-koordinator, see ack-koordinator (ack-slo-manager).

Billing

No fee is charged when you install and use the ack-koordinator component. However, fees may be charged in the following scenarios:

  • ack-koordinator is an non-managed component that occupies worker node resources after it is installed. You can specify the amount of resources requested by each module when you install the component.

  • By default, ack-koordinator exposes the monitoring metrics of features such as resource profiling and fine-grained scheduling as Prometheus metrics. If you enable Prometheus metrics for ack-koordinator and use Managed Service for Prometheus, these metrics are considered as custom metrics and fees are charged for these metrics. The fee depends on factors such as the size of your cluster and the number of applications. Before you enable Prometheus metrics, we recommend that you read the Billing topic of Managed Service for Prometheus to learn the free quota and billing rules of custom metrics. For more information about how to monitor and manage resource usage see Query the amount of observable data and bills.

Procedure

  1. Create a file named configmap.yaml based on the following ConfigMap content:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: ack-slo-config
      namespace: kube-system
    data:
      # Enable CPU Suppress. 
      resource-threshold-config: |
        {
          "clusterStrategy": {
            "enable": true
          }
        }
  2. Check whether the ack-slo-config ConfigMap exists in the kube-system namespace.

    • If the ack-slo-config ConfigMap exists, we recommend that you run the kubectl patch command to update the ConfigMap. This avoids changing other settings in the ConfigMap.

      kubectl patch cm -n kube-system ack-slo-config --patch "$(cat configmap.yaml)"
    • If ack-slo-config ConfigMap does not exist, run the following command to create a ConfigMap named ack-slo-config:

      kubectl apply -f configmap.yaml
  3. Run the following command to query the CPU cores that are allocated to the BE pods on the node:

    cat /sys/fs/cgroup/cpuset/kubepods.slice/kubepods-besteffort.slice/cpuset.cpus

    Expected output:

    10-25,35-51,62-77,87-103

    The output shows that the following CPU cores are allocated to the BE pods on the node: 10-25, 35-51, 62-77, and 87-103.

  4. Optional: Configure advanced parameters based on the following ConfigMap content.

    CPU Suppress allows you to configure the CPU utilization threshold in a fine-grained manner.

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: ack-slo-config
      namespace: kube-system
    data:
      resource-threshold-config: |
        {
          "clusterStrategy": {
            "enable": true,
            "cpuSuppressThresholdPercent": 65
          }
        }

    The following table describes the parameters.

    Parameter

    Type

    Valid value

    Description

    enable

    Boolean

    • true

    • false

    • : enables CPU Suppress.

    • : disables CPU Suppress.

    cpuSuppressThresholdPercent

    Int

    0~100

    The CPU utilization threshold of the node. Unit: %. Default value: 65.