k8s hpa can't get the cpu information [closed] k8s hpa can't get the cpu information [closed] kubernetes kubernetes

k8s hpa can't get the cpu information [closed]


With Kubernetes 1.18 and Metrics v0.3.7 we should edit the metrics-server deployment to reflect the following argument:

args:  - --kubelet-insecure-tls  - --kubelet-preferred-address-types=InternalIP  - --cert-dir=/tmp  - --secure-port=4443


Thank you weibeld and EAT_Py. I have resolved this problem.The debug process:

sudo kubectl get --raw "/apis/metrics.k8s.io/v1beta1/namespaces/k8s-demo/pods"sudo kubectl -n kube-system logs metrics-server-795b774c76-t2rj7sudo kubectl top node nandoc-94   -->can't get infosudo kubectl top pod k8s-pod-e7-build-32-7bb5bc7c6-s2zsr   -->can't get info

the logs of metrics-server has some error info:

kubelet_summary:nandoc-93: unable to fetch metrics from Kubelet nandoc-93 (nandoc-93): Get https://nandoc-93:10250/stats/summary?only_cpu_and_memory=true: x509: certificate signed by unknown authority]

Then according to https://github.com/kubernetes-sigs/metrics-server/issues/146I edit metrics-server/deploy/1.8+/metrics-server-deployment.yaml and add the command

  - name: metrics-server    image: k8s.gcr.io/metrics-server-amd64:v0.3.6    command:    - /metrics-server    - --kubelet-insecure-tls

kubectl apply -f metrics-server-deployment.yaml

After that, kubectl top pod work ok.And hpa works now. Thank you again.

sudo kubectl get hpa --all-namespacesNAMESPACE   NAME              REFERENCE                        TARGETS   MINPODS   MAXPODS   REPLICAS   AGEk8s-demo    hpa-e7-build-32   Deployment/k8s-pod-e7-build-32   0%/10%    1         2         1          19hk8s-demo    hpa-e7-build-64   Deployment/k8s-pod-e7-build-64   0%/10%    1         2         1          19h