HPA Metrics

Last updated: 2020-05-25 09:34:49

    Horizontal Pod Autoscaler (HPA) uses various metrics, such as target instance CPU usage, to adjust the number of Pods to automatically scale in or out. You can use the console to configure these metrics, including CPU, memory, disk, network, and GPU metrics. You can also use YAML files to create or modify HPAs. This article also contains a sample YAML file.

    Metrics

    The following table is a list of metrics used the HPA:

    Each variable in the metricName column has a Default unit. You can omit such units when editing the YAML file.

    CPU metrics

    Metric name (Console)Unit (Console)Description TypemetricNameDefault unit
    CPU utilization Cores CPU utilization of the Pod Pods k8s_pod_cpu_core_used Cores
    CPU utilization
    (% of total resources)
    % The percentage of the CPU utilization out of all cores allocated to the Pod. Pods k8s_pod_rate_cpu_core_used_resource %
    CPU utilization
    (% of request)
    % The percentage of CPU utilization to the request value Pods k8s_pod_rate_cpu_core_used_request %
    CPU utilization
    (% of limit)
    % The percentage of CPU utilization to the limit value Pods k8s_pod_rate_cpu_core_used_limit %

    Memory metrics

    Metric name (Console)Unit (Console)Description TypemetricNameDefault unit
    Memory usage Mib Pod memory usage Pods k8s_pod_mem_usage_bytes B
    Memory utilization
    (% of allocated resources)
    % The percentage of used memory out of all memory allocated to the Pod. Pods k8s_pod_rate_mem_usage_bytes_resource %
    Memory utilization
    (% of request)
    % The percentage of memory usage to the request value Pods k8s_pod_rate_mem_usage_request %
    Memory utilization
    (% of limit)
    % The percentage of memory usage to the limit value Pods k8s_pod_rate_mem_usage_limit %

    Using YAML files to Create and Modify HPAs

    You can use YAML files to create and edit HPAs. The following is a sample YAML file. It creates an HPA called example which is triggered when CPU utilization reaches 1 and the number of Pods ranges from 1 to 2.

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

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help