kubectl 提供了top去查看node 和 pod 的资源使用,但是kubeadm部署k8s集群后,kubectl top node/pod 就会报错 Error from server (NotFound): the server could not find the requested resource (get services http:heapster:), 这就需要自己去安装metrics-server,才能正常使用kubectl top node/pod,metrics-server是资源使用数据的群集范围聚合器.
下载metrics-server 部署yaml
1 | git clone https://github.com/kubernetes-incubator/metrics-server.git |
修改metrics-server-deployment.yaml
1 | - name: metrics-server |
安装metrics-server
1 | cd metrics-server && kubectl apply -f deploy/1.8+/ |
配置coredns configmap
安装过后执行”kubectl top node” 会报错”error: metrics not available yet”,查看metrics-server log 会发现 “unable to fetch pod metrics for pod default/web-nginx-6fdb6bdd5c-qzmx5: no metrics known for pod”,这是metrics-server 不能解析集群内主机的主机名,所一要配置下coredns,增加hosts {}
1 | apiVersion: v1 |
验证
1 | $ [K8sSj] kubectl top node |
- 本文作者: ChuLinx
- 本文链接: http://yoursite.com/2019/11/30/kubernetes1.14安装metrics-server/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!