You need to enable JavaScript to run this app.
Volcengine Kubernetes Engine

Volcengine Kubernetes Engine

Copy page
Download PDF
Horizontal Pod Autoscaler (HPA)
Achieving autoscaling by using GPU and network metrics
Copy page
Download PDF
Achieving autoscaling by using GPU and network metrics
In addition to the built-in CPU and memory metrics supported by Kubernetes, Volcengine Kubernetes Engine(VKE) also provides pre-configured rules for GPU and network metrics. This allows autoscaling to be triggered based on GPU usage or network traffic of containers. This topic describes how to configure an autoscaler based on the GPU or network metric.​
Background information​
Description​
By default, a Horizontal Pod Autoscaler (HPA) supports automatic scaling only based on CPU and memory usage. It cannot meet scaling requirements in complex scenarios. For example, production environments often expect scaling based on GPU usage or network traffic of pods.​
VKE provides the prometheus-adapter add-on to address this issue. It exposes native Prometheus metrics in the Custom Metrics API format and comes pre-configured with conversion rules for GPU and network metrics. After you enable cloud native observability for a cluster, you can configure automatic workload scaling for greater stability and cost-efficiency based on collected GPU and network metric data. ​
Autoscaling based on GPU usage and network involves the following major steps:​
  1. Install the prometheus-adapter add-on in the cluster.​
  1. Enable cloud native observability in the cluster and collect relevant metrics. For details, see Enabling observability and Basic observability.​
  1. Configure an HPA to implement workload autoscaling based on GPU usage or network traffic.​
Metrics​
VKE supports autoscaling based on GPU and network metrics of workloads. The following table describes the preset metrics.​
​
Metric description​
Metric name​
Unit​
GPU usage​
k8s_pod_rate_gpu_used​
%​
GPU memory usage​
k8s_pod_rate_gpu_memory_used​
%​
GPU memory used​
k8s_pod_gpu_memory_used​
MiB​
Network receive throughput​
k8s_pod_network_receive_throughput​
%​
Network transmit throughput​
k8s_pod_network_transmit_throughput​
%​
​
tip​
  • In the kube-system namespace, you can check prometheus-adapter-config to verify preset metric names and the corresponding Prometheus metrics.​
Usage limits​
  • If multiple metrics are specified in an HPA, the calculation is done for each metric, and then the largest of the desired replica counts is chosen.​
  • An HPA applies only to Deployments, Statefulsets and CustomResourceDefinitions (CRDs).​
  • HPAs for GPU-based autoscaling support only GPU pods, not mGPU pods.​
Prerequisites​
  • The nvidia-device-plugin add-on has been installed with the Install dcgm-exporter option selected for Deploy addons. For details, see nvidia-device-plugin.​
  • The prometheus-agent add-on has been installed with the Install node-exporter option selected for Deploy addons. For details, see prometheus-agent.​
Creating through the console​
  1. Log in to the VKE console.​
  1. In the left navigation bar, click Cluster.​
  1. In the cluster list, click the target cluster.​
  1. In the left navigation bar on the cluster management page, click Autoscaling > HPA. On the page that appears, click Create HorizontalPodAutoscaler and configure parameters as needed.​
  • Basic information​
  • ​
    Parameters​
    Description​
    Name​
    Enter a name that complies with the displayed naming rules. The name must be unique within the same namespace.​
    Namespace​
    Select the namespace to which the autoscaler belongs. We recommend that you select a custom namespace or the default namespace created by the system. For details about namespaces, see Namespace overview.​
    Label​
    Add Kubernetes labels to specify identifying attributes of the autoscaler. Click Add new and then enter a key-value pair that complies with the on-screen requirements.​
    Annotation​
    Create Kubernetes annotations to attach non-identifying metadata to this autoscaler for efficient metadata retrieval. Annotations can contain characters that are not permitted in labels. Click Add annotation and then enter a key-value pair that complies with the on-screen requirements.​
    ​
  • Scaling policy​
  • ​
    Parameters​
    Description​
    Scaling object​
    Specify the object for autoscaling. You can specify a Deployment, StatefulSet, or Custom resource object. After specifying the type of the object for autoscaling, select a specific object from the drop-down list.​
    Monitoring metrics​
    Configure the metrics based on which scaling is performed. The GPU and network metrics supported in VKE include:​
    • GPU usage - the average GPU usage of all pod replicas for the workload. When the GPU usage reaches this specified value, scaling is triggered.​
    • GPU memory usage - the percentage of the total usage of GPU video memory shared by all pods to the total GPU video memory requests shared by all pods. When the GPU video memory usage reaches this specified value, scaling is triggered.​
    • GPU memory - the shared GPU video memory used by all pods. When the GPU video memory size reaches this specified value, scaling is triggered.​
    • Network receive throughput - the sum of inbound bandwidth for all containers in all pods for the workload. When the network receive throughput reaches this specified value, scaling is triggered.​
    • Network transmit throughput - the sum of outbound bandwidth for all containers in all pods for the workload. When the network transmit throughput reaches this specified value, scaling is triggered.​
    tip​
    • An HPA configuration cannot contain duplicate scaling metrics in the same category.​
    • Currently, a maximum of two metrics can be included.​
    • For information about how to configure autoscaling based on CPU and memory usage, see Creating HPA.​
    Minimum number of instances​
    Configure the minimum and maximum replica counts for scaling. When the policy is triggered, workload instances will scale within this range.​
    Maximum number of instances​
    ​
    ​
  • Scaling rule​
  • ​
    Parameter​
    Description​
    Scaling policy​
    Select Scale-out policy and Scale-in policy to configure the workload scale-in and scale-out behavior.​
    Silence time​
    Specify the cooldown period for the scale-out or scale-in policy. The value is an integer in seconds.​
    After the system completes scaling, the scaling policy will not be executed again during the quiet time. This prevents frequent changes in the number of workload replicas that lead to system instability.​
    Policy type​
    Specify the policy type. Valid values:​
    • Maximum value: executes the policy that has the most impact on pod count.​
    • Minimum value: executes the policy that has the least impact on pod count.​
    • Disable: disables the scale-out policy or scale-in policy.​
    Policy​
    Configure the scaling policy content, including the following items:​
    • Type: specifies the type of scaling policy behavior.​
    • Pod: performs scaling based on the number of pods.​
    • Percentage: performs scaling based on the percentage of pods.​
    • Threshold: specifies the threshold for scaling. This parameter needs to be used together with Type. For example, if you set the Type parameter to Pod and set the threshold to 10, it indicates that 10 replicas will be scaled out or scaled in within the time interval.​
    • Time interval: Specify the interval at which scaling is performed. The value is an integer. Valid values: 1 to 1800. Unit: seconds.​
    ​
  1. Click Confirm.​
Use kubectl​
Use the following code example to create an HPA associated with the object for autoscaling based on GPU utilization.​
​
apiVersion: autoscaling/v2​
kind: HorizontalPodAutoscaler​
metadata:​
name: gpu-hpa # The HPA name.​
spec:​
scaleTargetRef:​
apiVersion: apps/v1​
kind: Deployment # The type of the object for autoscaling. Supported types include Deployment, StatefulSet, and CustomResourceDefinition.​
name: deployment-demo # The object instance for autoscaling.​
minReplicas: 1 # The minimum number of replicas.​
maxReplicas: 10 # The maximum number of replicas.​
metrics:​
- type: Pods​
pods:​
metric:​
name: k8s_pod_rate_gpu_used # The metric that triggers the HPA. In this example, it is pod GPU utilization.​
target:​
averageValue: 20 # When GPU utilization exceeds 20%, a scale-out is triggered.​
type: AverageValue​
​
Validating results​
Viewing configuration​
In the left navigation bar, click Autoscaling > HPA to view the configured HPA.​
Validating scaling results​
  1. When pod GPU usage increases, a scale-out will be triggered. You can view HPA information by using the following command:​
  • ​
    kubectl get hpa​
    ​
  • The expected outcome is an increase in the Deployment replicas to 2, as demonstrated below:​
  • ​
    NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE​
    gpu-hpa Deployment/example-gpu-workload 23/20 1 10 2 62s ​
    ​
  1. When the GPU usage of pods drops below the specified value, a scale-in is triggered. You can use the following command to view HPA information:​
  • ​
    kubectl get hpa​
    ​
  • The expected outcome is a decrease in the Deployment replicas to 1, as demonstrated below:​
  • ​
    NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE​
    gpu-hpa Deployment/example-gpu-workload 0/20 1 10 1 15m​
    ​
References​
Different versions of HPA resources provide varied levels of granular control over scaling behavior. For details, see Kubernetes documentation.​
When you configure workload autoscaling to meet your business requirements, consider the Kubernetes version that you are using.​
​
Last updated: 2026.07.24 14:51:37