问题

部署METRICS-SERVER时遇到的问题

[root@k8s-master-1 metrics-server]# kubectl top no
Error from server (ServiceUnavailable): the server is currently unable to handle the request (get nodes.metrics.k8s.io)

查看metrics-server日志正常

[root@k8s-master-1 metrics-server]# kubectl logs -n kube-system deploy/metrics-server 
I0719 11:24:01.344097       1 serving.go:312] Generated self-signed cert (/tmp/apiserver.crt, /tmp/apiserver.key)
I0719 11:24:01.679086       1 secure_serving.go:116] Serving securely on [::]:4443

查看kube-apiserver日志,发现:

v1beta1.metrics.k8s.io failed with: failing or missing response from https://10.96.142.17:443/apis/metrics.k8s.io/v1beta1: Get https://10.96.142.17:443/apis/metrics.k8s.io/v1beta1: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

解决方法:在kube-apiserver选项中添加如下配置选项:

# kubeadm 文件位置: /etc/kubernetes/manifests/kube-apiserver.yaml,二进制自己知道
--enable-aggregator-routing=true
[root@k8s-master-1 metrics-server]# kubectl top node 
NAME           CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
k8s-master-1   196m         9%     1284Mi          34%       
k8s-node-1     46m          2%     720Mi           19%       
k8s-node-2     46m          2%     704Mi           19%  

移除节点无法加入

在被删除的 node 节点中执行,清空集群数据信息。

kubeadm reset 之后再加入

Last updated