一、下载资源并解压
wget https://github.com/kubernetes-sigs/metrics-server/archive/v0.3.6.tar.gz
tar -zxvf v0.3.6.tar.gz
二、修改文件
cd metrics-server-0.3.6/deploy/1.8+/
vim metrics-server-deployment.yaml
修改后:
metadata:
name: metrics-server
namespace: kube-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: metrics-server
namespace: kube-system
labels:
k8s-app: metrics-server
spec:
selector:
matchLabels:
k8s-app: metrics-server
template:
metadata:
name: metrics-server
labels:
k8s-app: metrics-server
spec:
serviceAccountName: metrics-server
volumes:
# mount in tmp so we can safely use from-scratch images and/or read-only containers
- name: tmp-dir
emptyDir: {}
containers:
- name: metrics-server
image: mirrorgooglecontainers/metrics-server-amd64:v0.3.6
imagePullPolicy: IfNotPresent
command:
- /metrics-server
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalDNS,InternalIP,ExternalDNS,ExternalIP,Hostname
volumeMounts:
- name: tmp-dir
mountPath: /tmp
# insert resources
resources:
limits:
cpu: 300m
memory: 200Mi
requests:
cpu: 200m
memory: 100Mi
三、安装和检查
kubectl apply -f metrics-server-0.3.6/deploy/1.8+/
# wait about 1 miniutes
kubectl top node 可以查看到节点的使用情况,但是后面发现pod无法检测
四、新问题未解决
kubectl top pods 报错
top_pod.go:265] Metrics not available for pod
尝试多种方式重新配置也没有解决这个问题,甚至重启kubectl、重启节点都没有解决问题。在此记录一下。。
补充记录,不出意外应该是版本问题导致的问题。如docker1.18版本下装kubernetes1.19不行,但是将kubernetes1.19调整成kubernetes1.17没问题(来自博友的回答,此处未验证)。
上一篇:kubernetes解决ingress代理前后端分离pod之间的跨域问题——<09>
下一篇:kubernetes集群环境指定pod运行的节点——<11>
参考文章1:https://misa.gitbook.io/k8s-ocp-yaml/kubernetes-docs/2020-04-14-metrics-server
参考文章2:https://github.com/kubernetes-sigs/metrics-server/issues/300
参考文章:https://blog.csdn.net/l1028386804/article/details/105902731