Updated on 2024-09-30 GMT+08:00

Kubernetes Metrics Server

From version 1.8 onwards, Kubernetes provides resource usage metrics, such as the container CPU and memory usage, through the Metrics API. These metrics can be directly accessed by users (for example, by using the kubectl top command) or used by controllers (for example, Horizontal Pod Autoscaler) in a cluster for decision-making. The specific component is metrics-server, which is used to substitute for heapster for providing the similar functions. heapster has been gradually abandoned since v1.11.

metrics-server is an aggregator for monitoring data of core cluster resources. You can quickly install this add-on on the CCE console.

After installing this add-on, you can create HPA policies. For details, see Creating an HPA Policy.

The official community project and documentation are available at https://github.com/kubernetes-sigs/metrics-server.

Installing the Add-on

  1. Log in to the CCE console and click the cluster name to access the cluster console. In the navigation pane, choose Add-ons, locate Kubernetes Metrics Server on the right, and click Install.
  2. On the Install Add-on page, configure the specifications as needed.

    • If you selected Preset, you can choose between Small or Large as needed. The system will automatically set the number of add-on pods and resource quotas according to the preset specifications. You can see the configurations on the console.

      The smaller specification lacks HA capabilities, while the large specification has them. However, deploying multiple pods requires more compute resources.

    • If you selected Custom, you can adjust the number of pods and resource quotas as needed. High availability is not possible with a single pod. If an error occurs on the node where the add-on instance runs, the add-on will fail.

  3. Configure deployment policies for the add-on pods.

    • Scheduling policies do not take effect on add-on instances of the DaemonSet type.
    • When configuring multi-AZ deployment or node affinity, ensure that there are nodes meeting the scheduling policy and that resources are sufficient in the cluster. Otherwise, the add-on cannot run.
    Table 1 Configurations for add-on scheduling

    Parameter

    Description

    Multi AZ

    • Preferred: Deployment pods of the add-on will be preferentially scheduled to nodes in different AZs. If all the nodes in the cluster are deployed in the same AZ, the pods will be scheduled to different nodes in that AZ.
    • Equivalent mode: Deployment pods of the add-on are evenly scheduled to the nodes in the cluster in each AZ. If a new AZ is added, you are advised to increase add-on pods for cross-AZ HA deployment. With the Equivalent multi-AZ deployment, the difference between the number of add-on pods in different AZs will be less than or equal to 1. If resources in one of the AZs are insufficient, pods cannot be scheduled to that AZ.
    • Required: Deployment pods of the add-on are forcibly scheduled to nodes in different AZs. There can be at most one pod in each AZ. If nodes in a cluster are not in different AZs, some add-on pods cannot run properly. If a node is faulty, add-on pods on it may fail to be migrated.

    Node Affinity

    • Not configured: Node affinity is disabled for the add-on.
    • Node Affinity: Specify the nodes where the add-on is deployed. If you do not specify the nodes, the add-on will be randomly scheduled based on the default cluster scheduling policy.
    • Specified Node Pool Scheduling: Specify the node pool where the add-on is deployed. If you do not specify the node pool, the add-on will be randomly scheduled based on the default cluster scheduling policy.
    • Custom Policies: Enter the labels of the nodes where the add-on is to be deployed for more flexible scheduling policies. If you do not specify node labels, the add-on will be randomly scheduled based on the default cluster scheduling policy.

      If multiple custom affinity policies are configured, ensure that there are nodes that meet all the affinity policies in the cluster. Otherwise, the add-on cannot run.

    Toleration

    Using both taints and tolerations allows (not forcibly) the add-on Deployment to be scheduled to a node with the matching taints, and controls the Deployment eviction policies after the node where the Deployment is located is tainted.

    The add-on adds the default tolerance policy for the node.kubernetes.io/not-ready and node.kubernetes.io/unreachable taints, respectively. The tolerance time window is 60s.

    For details, see Configuring Tolerance Policies.

  4. Click Install.

Components

Table 2 Add-on components

Component

Description

Resource Type

metrics-server

Aggregator for the monitored data of cluster core resources, which is used to collect and aggregate resource usage metrics obtained through the Metrics API in the cluster

Deployment

Change History

Table 3 Release history

Add-on Version

Supported Cluster Version

New Feature

Community Version

1.3.68

v1.21

v1.23

v1.25

v1.27

v1.28

v1.29

v1.30

CCE clusters 1.30 are supported.

0.6.2

1.3.60

v1.21

v1.23

v1.25

v1.27

v1.28

v1.29

CCE clusters 1.29 are supported.

0.6.2

1.3.39

v1.21

v1.23

v1.25

v1.27

v1.28

Fixed some issues.

0.6.2

1.3.37

v1.21

v1.23

v1.25

v1.27

v1.28

CCE clusters 1.28 are supported.

0.6.2

1.3.12

v1.19

v1.21

v1.23

v1.25

v1.27

None

0.6.2

1.3.8

v1.19

v1.21

v1.23

v1.25

Synchronized time zones used by the add-on and the node.

0.6.2

1.3.6

v1.19

v1.21

v1.23

v1.25

  • Supported anti-affinity scheduling of add-on pods on nodes in different AZs.
  • The default taint tolerance duration is changed to 60s.

0.6.2

1.3.3

v1.19

v1.21

v1.23

v1.25

  • CCE clusters 1.25 are supported.
  • Allowed CronHPA to adjust the number of Deployment pods with the skip scenario supported.

0.6.2

1.3.2

v1.19

v1.21

v1.23

v1.25

CCE clusters 1.25 are supported.

0.6.2

1.2.1

v1.19

v1.21

v1.23

CCE clusters 1.23 are supported.

0.4.4

1.1.10

v1.15

v1.17

v1.19

v1.21

CCE clusters 1.21 are supported.

0.4.4

1.1.4

v1.15

v1.17

v1.19

Unified resource specification configuration unit.

0.4.4

1.1.2

v1.15

v1.17

v1.19

Updated the add-on to its community version v0.4.4.

0.4.4

1.1.1

v1.13

v1.15

v1.17

v1.19

Allows you to change the maximum number of invalid pods to 1.

0.3.7

1.1.0

v1.13

v1.15

v1.17

v1.19

CCE clusters 1.19 are supported.

0.3.7

1.0.5

v1.13

v1.15

v1.17

Updated the add-on to its community version v0.3.7.

0.3.7