tencent cloud

Feedback

HPA Metrics

Last updated: 2022-06-10 19:32:51

    Horizontal Pod Autoscaler (HPA) can automatically adjust the number of Pods for services according to the average CPU utilization of target Pods and other metrics. You can set auto scaling triggering metrics in the console, including CPU, memory, disk, network, and GPU metrics. You can also use these metrics when creating and editing HPAs through YAML files. This document describes how to configure a YAML file.

    Auto Scaling Metrics

    The following tables list the details of the auto scaling metrics:

    Note:

    Each variable under metricName has its own unit that is listed in the default unit column. You can omit such units when compiling the YAML file.

    CPU metrics

    Metric Name in the ConsoleUnit in the ConsoleRemarks typemetricNameDefault Unit
    CPU Usage Core Number of CPU cores used by the Pod Pods k8s_pod_cpu_core_used Core
    CPU Utilization
    (per node)
    % Percentage of total CPU of the node used by the Pod Pods k8s_pod_rate_cpu_core_used_node %
    CPU Utilization
    (per Request)
    % Ratio of the total number of CPU cores used by the Pod and the value of Request specified by the container in the Pod Pods k8s_pod_rate_cpu_core_used_request %
    CPU Utilization
    (per Limit)
    % Ratio of the total number of CPU cores used by the Pod and the sum of Limit specified by the container in the Pod Pods k8s_pod_rate_cpu_core_used_limit %

    Disk metrics

    Metric Name in the ConsoleUnit in the ConsoleRemarks typemetricNameDefault Unit
    Disk Write Traffic KB/s Pod's disk write rate Pods k8s_pod_fs_write_bytes B/s
    Disk Read Traffic KB/s Pod's disk read rate Pods k8s_pod_fs_read_bytes B/s
    Disk Read IOPS Times/s Number of I/O times Pod reads data from disk Pods k8s_pod_fs_read_times Times/s
    Disk Write IOPS Times/s Number of I/O times Pod writes data to disk Pods k8s_pod_fs_write_times Times/s

    Network

    Metric Name in the ConsoleUnit in the ConsoleRemarks typemetricNameDefault Unit
    Inbound Network Bandwidth Mbps Sum of inbound bandwidth of all containers per Pod Pods k8s_pod_network_receive_bytes_bw Bps
    Outbound Network Bandwidth Mbps Sum of outbound bandwidth of all containers per Pod Pods k8s_pod_network_transmit_bytes_bw Bps
    Inbound Network Traffic KB/s Sum of inbound traffic of all containers per Pod Pods k8s_pod_network_receive_bytes B/s
    Outbound Network Traffic KB/s Sum of outbound traffic of all containers per Pod Pods k8s_pod_network_transmit_bytes B/s
    Network Packets In Count/s Sum of inbound packets of all containers per Pod Pods k8s_pod_network_receive_packets Count/s
    Network Packets Out Count/s Sum of outbound packets of all containers per Pod Pods k8s_pod_network_transmit_packets Count/s

    Memory

    Metric Name in the ConsoleUnit in the ConsoleRemarks typemetricNameDefault Unit
    Memory usage MiB Amount of memory used by the pod Pods k8s_pod_mem_usage_bytes B
    Memory Usage
    (excluding cache)
    MiB Pod Memory Usage, excluding cache Pods k8s_pod_mem_no_cache_bytes B
    Memory Utilization
    (per node)
    % Percentage of total memory of the node used by the Pod Pods k8s_pod_rate_mem_usage_node %
    Memory Utilization
    (per node, excluding cache)
    % Percentage of total memory of the node used by the Pod, excluding cache Pods k8s_pod_rate_mem_no_cache_node %
    Memory Utilization
    (per Request)
    % Percentage of total memory of the Request used by the Pod Pods k8s_pod_rate_mem_usage_request %
    Memory Utilization
    (per Request, excluding cache)
    % Percentage of total memory of the Request used by the Pod, excluding cache Pods k8s_pod_rate_mem_no_cache_request %
    Memory Utilization
    (per Limit)
    % Percentage of Pod memory usage to the Limit value Pods k8s_pod_rate_mem_usage_limit %
    Memory Utilization
    (per Limit, excluding cache)
    % Percentage of Pod memory usage to the Limit value, excluding cache Pods k8s_pod_rate_mem_no_cache_limit %

    GPU

    Note:

    The following GPU-related triggering metrics can only be used in EKS clusters.

    Metric Name in the ConsoleUnit in the ConsoleRemarks typemetricNameDefault Unit
    GPU Usage CUDA Core Pod GPU usage Pods k8s_pod_gpu_used CUDA Core
    GPU Applications CUDA Core Pod GPU applications Pods k8s_pod_gpu_request CUDA Core
    GPU Utilization
    (per Request)
    % Percentage of GPU usage to the Request value Pods k8s_pod_rate_gpu_used_request %
    GPU Utilization
    (per node)
    % GPU usage percentage in the node Pods k8s_pod_rate_gpu_used_node %
    GPU Memory Usage Mib Pod GPU memory usage Pods k8s_pod_gpu_memory_used_bytes B
    GPU Memory Applications MiB Pod GPU memory applications Pods k8s_pod_gpu_memory_request_bytes B
    GPU Memory Utilization
    (per Request)
    % Percentage of GPU memory usage to the Request value Pods k8s_pod_rate_gpu_memory_used_request %
    GPU Memory Utilization
    (per node)
    % GPU memory usage percentage in the node Pods k8s_pod_rate_gpu_memory_used_node %

    Creating and Editing HPA Through YAML

    You can create and edit an HPA through a YAML file. Below is a sample configuration file that defines an HPA named example, which will be triggered when the CPU usage reaches 1. The instance range is 1–2.

    Note:

    TKE is compatible with the native Resource types.

    apiVersion: autoscaling/v2beta1
    kind: HorizontalPodAutoscaler
    metadata:
    name: example
    namespace: default
    labels:
      qcloud-app: example
    spec:
    minReplicas: 1
    maxReplicas: 2
    metrics:
    - type: Pods    # Support using Resource
      pods:
        metricName: k8s_pod_cpu_core_used
        targetAverageValue: "1"
    scaleTargetRef:
      apiVersion: apps/v1beta2
      kind: Deployment
      name: nginx
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support