安装过程参考https://blog.csdn.net/qq_40460909/article/details/93321945
git clone https://github.com/kubernetes-incubator/metrics-server.git
cd metrics-server/deploy/1.8+/
sed -i 's#k8s.gcr.io/metrics-server-amd64:v0.3.3#lanvv/metrics-server-amd64:v0.3.3#' metrics-server-deployment.yaml
sed -i '32a
args:
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP
- --metric-resolution=30s' metrics-server-deployment.yaml
kubectl create -f .
验证:
kubectl -n kube-system get pods
安装通过如上命令check pod 是running,但是kubectl top pod 报错:metrics-server: kubectl top nodes Error from server (ServiceUnavailable)
通过descibe pod 显示一切正常,通过kubectl logs -f pod/podname -c metrics-server 查看:serve.go:96] Serving securely on [::]:443
网上搜索,无果。
kubectl get pod -n kube-system 发现coredns没起来,通过describe pod发现:"cni0" already has an IP address different from ...
解决办法:
kubeadm reset
systemctl stop kubelet
systemctl stop docker
rm -rf /var/lib/cni/
rm -rf /var/lib/kubelet/*
rm -rf /etc/cni/
ifconfig cni0 down
ifconfig flannel.1 down
ifconfig docker0 down
ip link delete cni0
ip link delete flannel.1
systemctl start docker
kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=[IP地址] --kubernetes-version=v1.15.2
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/62e44c867a2846fefb68bd5f178daf4da3095ccb/Documentation/kube-flannel.ym
重新init master,加网络,join worker,确认coredns正常,然后再起metrices-server,ok