一、下载
git clone https://github.com/kubernetes-incubator/metrics-server.git
cd metrics-server-master/1.8+
二、修改yaml文件(镜像被墙)
vim metrics-server-deployment.yaml
修改内容:image:registry.cn-beijing.aliyuncs.com/xingshulin/metrics-server-amd64:v0.2.1
三、创建
kubectl create -f deploy/1.8+/
四、效果
刚搭建完会没有数据,过几分钟就能收集到数据了
[root@master 1.8+]# kubectl top nodes
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
master 153m 7% 2587Mi 33%
node001 34m 3% 616Mi 69%
node002 31m 3% 584Mi 65%
node003 39m 3% 574Mi 64%
五、解决错误
遇到的错误信息
E0725 10:12:12.679030 1 reststorage.go:128] unable to fetch node metrics for node "node002": no metrics known for node
E0725 10:12:12.679056 1 reststorage.go:128] unable to fetch node metrics for node "node003": no metrics known for node
E0725 10:12:12.679061 1 reststorage.go:128] unable to fetch node metrics for node "master": no metrics known for node
E0725 10:12:12.679066 1 reststorage.go:128] unable to fetch node metrics for node "node001": no metrics known for node
E0725 10:12:14.152632 1 reststorage.go:128] unable to fetch node metrics for node "node002": no metrics known for node
E0725 10:12:14.152656 1 reststorage.go:128] unable to fetch node metrics for node "node003": no metrics known for node
E0725 10:12:14.152662 1 reststorage.go:128] unable to fetch node metrics for node "master": no metrics known for node
E0725 10:12:14.152666 1 reststorage.go:128] unable to fetch node metrics for node "node001": no metrics known for node
E0725 10:12:15.344225 1 reststorage.go:128] unable to fetch node metrics for node "node003": no metrics known for node
E0725 10:12:15.344252 1 reststorage.go:128] unable to fetch node metrics for node "master": no metrics known for node
E0725 10:12:15.344257 1 reststorage.go:128] unable to fetch node metrics for node "node001": no metrics known for node
E0725 10:12:15.344261 1 reststorage.go:128] unable to fetch node metrics for node "node002": no metrics known for node
解决办法,修改metrics-server-deployment.yaml
--- a/deploy/1.8+/metrics-server-deployment.yaml
+++ b/deploy/1.8+/metrics-server-deployment.yaml
@@ -29,6 +29,10 @@ spec:
emptyDir: {}
containers:
- name: metrics-server
+ command:
+ - /metrics-server
+ - --kubelet-preferred-address-types=InternalIP
+ - --kubelet-insecure-tls
image: k8s.gcr.io/metrics-server-amd64:v0.3.3
imagePullPolicy: Always
volumeMounts:
重新部署
kubectl apply -f deploy/1.8+/
下面这篇文章写的不错
https://www.cnblogs.com/ding2016/p/10786252.html
遗憾的是,当前Kubernetes Dashboard还不支持metrics-server。因此如果使用metrics-server替代了heapster,将无法在dashboard中以图形展示Pod的内存和CPU情况。
网友评论