Installing the Metrics Server
The cross-cluster Horizontal Pod Autoscaler (HPA) uses the Metrics API in Kubernetes to obtain the resource usage in clusters. To use cross-cluster HPA, install the Metrics Server in the clusters. The Metrics Server obtains data through the Kubelet Summary API to implement the Metrics API. The Metrics API can query only the current data. Historical data cannot be queried in this way.
Prerequisites
- The cluster version must be later than 1.13.
- The VM where the Metrics Server is to be installed can be connected to the Internet and can perform operations on the cluster using kubectl.
Installing the Metrics Server
- Enable the API aggregation layer on the VM where the Metrics Server is to be installed. To be specific, set the following startup parameters on kube-APIServer:
For CCE clusters of Kubernetes 1.11, you need to submit a service ticket to enable the API aggregation layer. For CCE clusters of Kubernetes 1.13 or later version, the API aggregation layer is enabled by default.
--requestheader-client-ca-file= --proxy-client-cert-file= --proxy-client-key-file= --requestheader-allowed-names=aggregator --requestheader-extra-headers-prefix=X-Remote-Extra- --requestheader-group-headers=X-Remote-Group --requestheader-username-headers=X-Remote-User
Parameters are described as follows:
- --requestheader-client-ca-file: Root certificate bundle used to verify client certificates on incoming requests before trusting usernames in headers specified by --requestheader-username-headers.
- --proxy-client-cert-file: Client certificate used to prove the identity of the aggregator or kube-apiserver when it must call out during a request.
- --proxy-client-key-file: Private key for the client certificate used to prove the identity of the aggregator or kube-apiserver when it must call out during a request. This includes proxying requests to a user api-server and calling out to webhook admission plug-ins.
- --requestheader-allowed-names: List of common client certificate names to allow to provide usernames in headers specified by --requestheader-username-headers. If this parameter is left empty, any client certificate validated by the authorities in --requestheader-client-ca-file is allowed.
- --requestheader-extra-headers-prefix: List of header prefixes to be checked.
- --requestheader-group-headers: List of headers of groups to be checked.
- --requestheader-username-headers: List of headers of usernames to be checked.
If you are not running kube-proxy on a host running the API server, you must also configure the following parameter:
--enable-aggregator-routing=true
- Deploy the Metrics Server.
wget https://github.com/kubernetes-incubator/metrics-server/archive/v0.3.2.tar.gz tar zxvf v0.3.2.tar.gz cd metrics-server-0.3.2 kubectl create -f deploy/1.8+/
- Check whether metrics pods are successfully started.
kubectl get pods -nkube-system| grep metric
- If any pod in 3 is not started, run the following command to query logs:
kubectl logs {pod-name} -nkube-system
Query logs. If the error information shown in Figure 1 is displayed, run the following command:
kubectl edit deployment metrics-server -nkube-system
Add the startup parameter --kubelet-insecure-tls as shown in Figure 2, or configure a correct certificate (you need to provide the CA certificate of the Kubernetes cluster for metrics-server).
- Check whether data is obtained correctly.
kubectl get --raw /apis/metrics.k8s.io/v1beta1/nodes
If any command output is displayed, the installation is successful.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot