安装完metrics-server -v0.5.2版后,
# kubectl top nodes
Error from server (ServiceUnavailable): the server is currently unable to handle the request (get nodes.metrics.k8s.io)
解决方式,修改yaml文件
kind: Deployment
spec:
template:
spec:
nodeName: k8s-master ##第一次改动,新增此行
containers:
- args:
.....
- --secure-port=4430 ##第三次改动,原4443改成4430
......
- --kubelet-insecure-tls ##第二次改动,新增此行
.......
ports:
- containerPort: 4430 ##第三次改动,原4443改成4430
改完看看下效果
# kubectl top pods -A
NAMESPACE NAME CPU(cores) MEMORY(bytes)
default mongo-75f59d57f4-f5s24 23m 81Mi
kube-system coredns-7d89d9b6b8-mtk84 4m 18Mi
kube-system coredns-7d89d9b6b8-x864t 2m 14Mi
kube-system etcd-k8s-master 32m 86Mi
kube-system kube-apiserver-k8s-master 127m 337Mi
kube-system kube-controller-manager-k8s-master 54m 54Mi
kube-system kube-flannel-ds-f467b 6m 36Mi
kube-system kube-flannel-ds-xb8lh 4m 31Mi
kube-system kube-proxy-2z76m 3m 17Mi
kube-system kube-proxy-6wkrd 1m 18Mi
kube-system kube-scheduler-k8s-master 15m 21Mi
kube-system metrics-server-7f965c6c96-c96xh 8m 21Mi
kubernetes-dashboard dashboard-metrics-scraper-856586f554-r2zfp 1m 15Mi
kubernetes-dashboard kubernetes-dashboard-67484c44f6-4wpw7 1m 16Mi
# kubectl top nodes
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
k8s-master 555m 27% 1503Mi 40%
k8s-node1 141m 7% 725Mi 19%
OK,搞定。