Notes for Automatic Scaling Indicators

Last updated: 2020-02-12 10:21:28

PDF

Horizontal Pod Autoscaler (HPA) can automatically scale 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. Such metrics include CPU, memory, disk, network, and GPU metrics. You can also use these metrics when creating and editing HPAs with YAML files. This document provides an example of configuring a YAML file.

Autoscaling Metrics

The following table provides details about autoscaling metrics:

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

CPU Metrics

Metric name (Console)Unit (Console)Description typemetricNameDefault unit
CPU usage Core(s) Pod’s CPU usage Pods k8s_pod_cpu_core_used Core(s)
CPU utilization
(% of node)
% Percentage of total CPU of the node used by the Pod Pods k8s_pod_rate_cpu_core_used_node %
CPU utilization
(% of request)
% Percentage of Pod’s CPU usage to the pre-set request value Pods k8s_pod_rate_cpu_core_used_request %
CPU utilization
(% of limit)
% Percentage of Pod’s CPU usage to the pre-set limit value Pods k8s_pod_rate_cpu_core_used_limit %

Disk Metrics

Metric name (Console)Unit (Console)Description typemetricNameDefault unit
Disk write traffic KB/s Pod’s disk write speed Pods k8s_pod_fs_write_bytes B/s
Disk read traffic KB/s Pod’s disk read speed 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 Metrics

Metric name (Console)Unit (Console)Description typemetricNameDefault unit
Network ingress bandwidth Mbps Sum of Pod’s ingress bandwidth Pods k8s_pod_network_receive_bytes_bw Bps
Network egress bandwidth Mbps Sum of Pod’s egress bandwidth Pods k8s_pod_network_transmit_bytes_bw Bps
Network ingress traffic KB/s Sum of Pod’s ingress traffic Pods k8s_pod_network_receive_bytes B/s
Network egress traffic KB/s Sum of Pod’s egress traffic Pods k8s_pod_network_transmit_bytes B/s
Network inbound packets Packets/s Sum of Pod’s inbound packets Pods k8s_pod_network_receive_packets Packets/s
Network outbound packets Packets/s Sum of Pod’s outbound packets Pods k8s_pod_network_transmit_packets Packets/s

Memory Metrics

Metric name (Console)Unit (Console)Description typemetricNameDefault unit
Memory usage Mib Pod memory usage 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
(% of node)
% Percentage of total memory of the node used by the Pod Pods k8s_pod_rate_mem_usage_node %
Memory utilization
(% of 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
(% of request)
% Percentage of Pod memory usage to the request value Pods k8s_pod_rate_mem_usage_request %
Memory utilization
(% of request, excluding cache)
% Percentage of Pod memory usage to the request value, excluding cache Pods k8s_pod_rate_mem_no_cache_request %
Memory utilization
(% of limit)
% Percentage of Pod memory usage to the limit value Pods k8s_pod_rate_mem_usage_limit %
Memory utilization
(% of limit, excluding cache)
% Percentage of Pod memory usage to the limit value, excluding cache Pods k8s_pod_rate_mem_no_cache_limit %

GPU Metrics

Metric name (Console)Unit (Console)Description 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
(% of request)
% Percentage of GPU usage to the request value Pods k8s_pod_rate_gpu_used_request %
GPU utilization
(% of node)
% Percentage of node taken up by GPU usage 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
(% of request)
% Percentage of GPU memory usage to the request value Pods k8s_pod_rate_gpu_memory_used_request %
GPU memory utilization
(% of node)
% Percentage of node taken up by GPU memory usage Pods k8s_pod_rate_gpu_memory_used_node %

Creating and Editing HPAs with YAML Files

You can create and edit HPAs with YAML files. The following example shows how to configure the file. This file defines an HPA named “test” which will be triggered when the CPU usage reaches 1 with the number of Pods ranging from 1 to 2.

{
    "kind":"HorizontalPodAutoscaler",
    "apiVersion":"autoscaling/v2beta1",
    "metadata":{
        "name":"ccc",
        "namespace":"kube-system",
        "labels":{
            "qcloud-app":"ccc"
        }
    },
    "spec":{
        "minReplicas":1,
        "maxReplicas":2,
        "metrics":[
            {
                "type":"Pods",
                "pods":{
                    "metricName":"k8s_pod_cpu_core_used",
                    "targetAverageValue":"1"
                }
            }
        ],
        "scaleTargetRef":{
            "apiVersion":"apps/v1beta2",
            "kind":"Deployment",
            "name":"cbs-provisioner"
        }
    }
}