解决:Unable to connect to the server: x509: certificate signed by unknown authority (possibly because

前提条件:之前搭建过k8s集群,使用 kubeadm reset 命令清除集群所有的配置之后,重新运行 kubectl get nodes 时报错:

[root@master ~]# kubectl get nodes
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")

运行kubeadm reset清除配置后,对集群初始化也是成功的

kubeadm init --kubernetes-version=1.26.3 --apiserver-advertise-address=10.0.0.32  --service-cidr=10.2.0.0/16 --pod-network-cidr=10.224.0.0/16

然而当运行 kubectl get nodes 时又报错..

原因:执行 kubeadm reset命令后没有删除创建的 .kube目录,重新创建集群就会出现这个问题!

解决:

rm -rf .kube/
sudo mkdir ~/.kube
sudo cp /etc/kubernetes/admin.conf ~/.kube/

cd ~/.kube
sudo mv admin.conf config
sudo service kubelet restart

技术性分享,转载请注明出处!

欢迎互相交流,共同进步!

你可能感兴趣的:(kubernetes,docker,容器)