部署Kubernetes遇到的问题与解决方法(初始化等)

Kubelet和control plane版本不对应:

[ERROR KubeletVersion]: the kubelet version is higher than the control plane version. This is not a supported version skew and may lead to a malfunctional cluster. Kubelet version: "1.19.4" Control plane version: "1.18.6"

解决:

#卸载重装对应的低版本
yum -y remove kubelet
yum -y install kubelet-1.18.6 kubeadm-1.18.6

master节点初始化之后执行 kubectl cluster-info 显示Unable to connect to the server:

Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

原因:Kebeadm init之后不删除元来文件并又新生成$HOME/.kube,重复了。要删干净文件后重新初始化。
解决:

#master节点执行:
rm -rf $HOME/.kube   #删掉所有文件
#重新执行生成文档:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl cluster-info

master节点:执行 kubectl get cs 显示unhealthy。变成healthy

步骤:
kubectl get cs
解决:

#改配置文件
#Master节点修改:
#vi /etc/kubernetes/manifests/kube-controller-manager.yaml
/etc/kubernetes/manifests/kube-scheduler.yaml
#两个文件都注释掉--port=0这个设置

 worker节点:The connection to the server localhost:8080 was refused – did you specify the right host or port?

[root@localhost kubelet.service.d]# kubectl get nodes
W1116 20:29:22.881159 20594 loader.go:223] Config not found: /etc/kubernetes/admin.conf
The connection to the server localhost:8080 was refused - did you specify the right host or port?

解决:

#Master节点执行:
scp /etc/kubernetes/admin.conf root@10.0.52.98:/etc/kubernetes/admin.conf
#Node节点执行:
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
source ~/.bash_profile

worker节点:不显示节点名称;两个节点名称一样只显示一个

解决:

hostnamectl set-hostname node2
hostname

重置kubeadm初始化/配置

Kubeadm reset
rm -rf /var/lib/cni/ /var/lib/etcd/
rm -rf /var/lib/kubelet /etc/kubernetes/
重新kubeadm init 和kubeadm join

worker节点执行 kubectl get nodes显示Not ready。变成ready:解决:

#Master和worker节点执行:
vi /var/lib/kubelet/kubeadm-flags.env:将“--network-plugin=cni”删掉
#重启:
systemctl daemon-reload
systemctl restart kubelet

kubeadm init初始化报错,无法拉取镜像:[ERROR ImagePull]: failed to pull image registry.aliyuncs.com/google_containers/coredns/coredns:v1.8.0
解决:

docker pull registry.aliyuncs.com/google_containers/coredns:1.8.0
docker tag registry.aliyuncs.com/google_containers/coredns:v1.8.0 registry.aliyuncs.com/google_containers/coredns/coredns:v1.8.0
docker rmi registry.aliyuncs.com/google_containers/coredns:1.8.0


原文链接:https://blog.csdn.net/clareeee/article/details/121100431

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?