参考文档:https://www.jianshu.com/p/262177fa9320
版本:metrics-server-amd64:v0.3.3
addon-resizer:1.8.4
[root@master metrics]# vim metrics-server-deployment.yaml
查看:
莫名其妙的一对报错,不错最终搞好了。
毫无里头报错:
[root@master ~]# kubectl logs metrics-server-v0.3.3-856bb6d5f8-55dbc -c metrics-server -n kube-system
aster: unable to fetch metrics from Kubelet master (192.168.19.134): Get https://192.168.19.134:10255/stats/summary/: dial tcp 192.168.19.134:10255: connect: connection refused, unable to fully scrape metrics from source kubelet_summary:node1: unable to fetch metrics from Kubelet node1 (192.168.19.133): Get https://192.168.19.133:10255/stats/summary/: dial tcp 192.168.19.133:10255: connect: connection refused, unable to fully scrape metrics from source kubelet_summary:node2: unable to fetch metrics from Kubelet node2 (192.168.19.135): Get https://192.168.19.135:10255/stats/summary/: dial tcp 192.168.19.135:10255: connect: connection refused]
[root@master ~]# kubectl logs metrics-server-v0.3.3-6448dcfb78-rrhd8 -c metrics-server-nanny -n kube-system
ERROR: logging before flag.Parse: I0528 06:16:58.415375 1 pod_nanny.go:138] Resources: [{Base:{i:{value:80 scale:-3} d:{Dec:<nil>} s:80m Format:DecimalSI} ExtraPerNode:{i:{value:5 scale:-4} d:{Dec:<nil>} s: Format:DecimalSI} Name:cpu} {Base:{i:{value:83886080 scale:0} d:{Dec:<nil>} s: Format:BinarySI} ExtraPerNode:{i:{value:8388608 scale:0} d:{Dec:<nil>} s: Format:BinarySI} Name:memory}]
需要修改的配置
[root@master metrics]# vim metrics-server-deployment.yaml
[root@master metrics]# vim resource-reader.yaml 增加 - nodes/stats,
测试正常显示:
[root@master yaml]# kubectl proxy --port=8080
[root@master ~]# kubectl top nodes
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% master 115m 5% 1186Mi 68% node1 18m 1% 265Mi 30% node2 34m 1% 502Mi 29% [root@master ~]# kubectl top podsNAME CPU(cores) MEMORY(bytes) default-http-backend-7784d46bf4-m62x5 1m 4Mi httpd-5d8cbbcd67-8pqnt 1m 12Mi myapp-deploy-677bbbb679-n2vhw 0m 2Mi myapp-deploy-677bbbb679-zjb5n 0m 2Mi pod-vol-hostpath 0m 2Mi redis-85b846ff9c-bsln6 1m 8Mi [root@master ~]# curl http://localhost:8080/apis/metrics.k8s.io/v1beta1/nodes{ "kind": "NodeMetricsList", "apiVersion": "metrics.k8s.io/v1beta1", "metadata": { "selfLink": "/apis/metrics.k8s.io/v1beta1/nodes" }, "items": [ { "metadata": { "name": "master", "selfLink": "/apis/metrics.k8s.io/v1beta1/nodes/master", "creationTimestamp": "2019-05-28T06:34:06Z" }, "timestamp": "2019-05-28T06:33:14Z",