kubectl top pods commands, whereas the Node metrics are currently used only in kubectl top nodes commands. TKE itself realizes the Resource Metrics API, pointed towards the hpa-metrics-server, and currently TKE also provides monitoring metrics for Pods.kubectl top nodes to obtain the monitoring overview of nodes to replace the realization of the Resource Metrics API. HPA created on the TKE console does not use Resource Metrics and only uses Custom Metrics. Therefore, installing the metrics-server does not affect HPA created on the TKE console. This document describes how to install the metrics-server on TKE.wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
--kubelet-insecure-tls launch parameter in the components.yaml file.
Moreover, as the official image repository of the metrics-server is stored in k8s.gcr.io, users in China may not be able to directly pull images from the repository. You need to manually synchronize images to CCR or use the synchronized image ccr.ccs.tencentyun.com/mirrors/metrics-server:v0.4.0.containers:- args:- --cert-dir=/tmp- --secure-port=4443 # Please replace with 4443- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname- --kubelet-use-node-status-port- --kubelet-insecure-tls # Add this launch parameterimage: ccr.ccs.tencentyun.com/mirrors/metrics-server:v0.4.0 # For cluster in the Chinese mainland, please replace with this image addressports:- containerPort: 4443 # Please replace with 4443name: httpsprotocol: TCP
kubectl apply -f components.yaml
kubectl apply -f https://raw.githubusercontent.com/TencentCloudContainerTeam/manifest/master/metrics-server/components.yaml
$ kubectl get pod -n kube-system | grep metrics-servermetrics-server-f976cb7d-8hssz 1/1 Running 0 1m
$ kubectl get --raw /apis/metrics.k8s.io/v1beta1 | jq{"kind": "APIResourceList","apiVersion": "v1","groupVersion": "metrics.k8s.io/v1beta1","resources": [{"name": "nodes","singularName": "","namespaced": false,"kind": "NodeMetrics","verbs": ["get","list"]},{"name": "pods","singularName": "","namespaced": true,"kind": "PodMetrics","verbs": ["get","list"]}]}
$ kubectl top nodesNAME CPU(cores) CPU% MEMORY(bytes) MEMORY%test1 1382m 35% 2943Mi 44%test2 397m 10% 3316Mi 49%test3 81m 8% 464Mi 77%
Feedback