1,虚拟机重启后使用kubectl命令报错
The connection to the server x.x.x.x:6443 was refused - did you specify the right host or port?
这是因为swap没有关。
#1,关闭swap
swapoff -a
#2,设置swap开机不启动
#将文件中的/dev/mapper/centos-swap swap swap defaults 0 0这一行注释掉
vi /etc/fstab
#3,同时调整k8s的swappiness参数
vi /etc/sysctl.d/k8s.conf
#添加一行vm.swappiness=0
#4,执行
sysctl -p /etc/sysctl.d/k8s.conf
2,如果没有关闭防火墙,把防火墙也关了
systemctl stop firewalld
并设置开机不启动
systemctl disable firewalld
3,kubectl get pods正常,但是发现dashboard打不开。
#1,查看dashboard状态发现Node is not ready
kubectl -n kubernetes-dashboard get service kubernetes-dashboard
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning NodeNotReady 9m27s node-controller Node is not ready
#2,查看node状态发现node的kube-proxy没有启动
kubectl describe node k8s-node1
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedToStartProxierHealthcheck 33h (x40850 over 3d18h) kube-proxy, k8s-node1 failed to start proxier healthz on 0.0.0.0:10256: listen tcp 0.0.0.0:10256: bind: address already in use
#3,到node虚拟机上执行 docker ps,发现容器为空。
#启动kubelet,并设置为开机启动
systemctl start kubelet
systemctl enable kubelet
#等待一会docker ps发现kubelet的相关服务启动,dashboard正常打开。