使用kubeadm reset之后,重新初始化之后,使用kubectl get pods命令时,出现:

[***@k8s-master-*** ***]$ kubectl get pods
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 init --kubernetes-version=v1.11.0 --apiserver-advertise-address=... 命令创建集群。提示执行以下几个命令:

 mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

查看发现,kubeadm reset时没有删除.kube目录下的文件,这里手动删除,然后再按上述步骤执行一遍,即可解决问题。
如下:

[***@k8s-master-*** ~]$ rm -rf .kube
[***@k8s-master-*** ~]$ mkdir -p .kube
[***@k8s-master-*** .kube]$ cd .kube
[***@k8s-master-*** .kube]$ sudo cp /etc/kubernetes/admin.conf config
[***@k8s-master-*** .kube]$ sudo chown $(id -u):$(id -g) config
[***@k8s-master-*** ~]$ kubectl get pods
No resources found.
[***@k8s-master-*** ~]$ kubectl get nodes
NAME              STATUS     ROLES     AGE       VERSION
k8s-master-***   NotReady   master    1d        v1.11.0

现在就可以将从节点加入集群了

参考(https://blog.csdn.net/woay2008/article/details/93250137

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐