Help Center/ Cloud Container Engine/ User Guide/ Scheduling/ GPU Scheduling/ GPU Auto Scaling/ Configuring Workload Scaling Based on GPU Monitoring Metrics
Updated on 2026-06-16 GMT+08:00

Configuring Workload Scaling Based on GPU Monitoring Metrics

In a standard or Turbo cluster, you can configure HPA policies for workloads that use GPU resources based on GPU monitoring metrics. This enables applications to automatically scale out during peak hours and scale in during off-peak hours, optimizing resource utilization and reducing costs.

Prerequisites

  • A cluster is available, and there are GPU nodes and GPU related services running in the cluster.
  • CCE AI Suite (NVIDIA GPU) has been installed in the cluster. The add-on can properly report GPU metrics. You can log in to the GPU node and run the following command:
    curl {Pod IP}:2112/metrics

    In the preceding command, {Pod IP} must be the pod IP address of nvidia-gpu-device-plugin in CCE AI Suite (NVIDIA GPU), and metric results are expected to be returned.

  • The Cloud Native Cluster Monitoring add-on of v3.9.5 or later has been installed in the cluster, and it is deployed in local data storage mode. Prometheus has been registered as a service that provides the Metrics API. For details, see Providing Basic Resource Metrics Through the Metrics API. If Kubernetes Metrics Server has been installed in the cluster, the Metrics API is provided by default. No manual registration is required.

Collecting GPU Metrics

  1. Log in to the CCE console and click the cluster name to access the cluster console. In the navigation pane, choose ConfigMaps and Secrets.
  2. Select the monitoring namespace. On the ConfigMaps tab, locate the row containing user-adapter-config and click Update.

    Figure 1 Updating a ConfigMap

  3. On the Update ConfigMap page, click Edit in the Operation column of the config.yaml file in the Data pane. Then, add a custom metric collection rule under the rules field. Click OK.

    You can add multiple collection rules by adding multiple configurations under the rules field. For details, see Metrics Discovery and Presentation Configuration.

    The following is an example of a custom rule for collecting cce_gpu_memory_utilization. For details about more GPU metrics, see GPU Metrics.
    rules:
    - seriesQuery: '{__name__=~"cce_gpu_memory_utilization",container!="",namespace!="",pod!=""}'
      seriesFilters: []
      resources:
        overrides:
          namespace:
            resource: namespace
          pod:
            resource: pod
      metricsQuery: sum(last_over_time(<<.Series>>{<<.LabelMatchers>>}[1m])) by (<<.GroupBy>>) * 100
    Figure 2 Customizing a collection rule

  4. Redeploy the custom-metrics-apiserver workload in the monitoring namespace.

    Figure 3 Redeploying custom-metrics-apiserver

  5. After the restart, check whether the metrics in the target pod are normal (replace the namespace and service pod names).

    1. Obtain metrics.
      kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1"

      Information similar to the following is displayed:

      {"kind":"APIResourceList","apiVersion":"v1","groupVersion":"custom.metrics.k8s.io/v1beta1","resources":[{"name":"pods/cce_gpu_memory_utilization","singularName":"","namespaced":true,"kind":"MetricValueList","verbs":["get"]},{"name":"namespaces/cce_gpu_memory_utilization","singularName":"","namespaced":false,"kind":"MetricValueList","verbs":["get"]}]}
    2. Obtain the metric value of the workload. test-685b6854b4-5nq5c specifies a pod name.
      kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/test-685b6854b4-5nq5c/cce_gpu_memory_utilization"

      Information similar to the following is displayed:

      {"kind":"MetricValueList","apiVersion":"custom.metrics.k8s.io/v1beta1","metadata":{},"items":[{"describedObject":{"kind":"Pod","namespace":"default","name":"test-685b6854b4-5nq5c","apiVersion":"/v1"},"metricName":"cce_gpu_memory_utilization","timestamp":"2026-01-17T10:03:16Z","value":"0","selector":null}]}

Creating an Auto Scaling Policy

  1. Choose Workloads in the navigation pane. Locate the target workload and choose Auto Scaling in the Operation column.
  2. Set Policy Type to HPA+CronHPA and enable HPA.

    You can select GPU monitoring parameters in Custom Policy to create an auto scaling policy. The following is an example.

    Figure 4 Selecting custom metrics

    In this example, cce_gpu_memory_utilization (GPU memory usage) is used as the scaling metric. For details about how to configure other HPA parameters, see Creating an HPA Policy.

  3. Return to the Scaling Policies tab and check whether the HPA policy has been created.

    Figure 5 HPA policy created