问题
执行kubectl get pods
的时候出现以下内容,
E0410 22:54:36.968355 2502 memcache.go:265] couldn't get current server API group list: Get "https://192.168.4.5:6443/api?timeout=32s": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
E0410 22:54:36.982819 2502 memcache.go:265] couldn't get current server API group list: Get "https://192.168.4.5:6443/api?timeout=32s": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
E0410 22:54:36.997249 2502 memcache.go:265] couldn't get current server API group list: Get "https://192.168.4.5:6443/api?timeout=32s": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
E0410 22:54:37.012764 2502 memcache.go:265] couldn't get current server API group list: Get "https://192.168.4.5:6443/api?timeout=32s": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
E0410 22:54:37.027750 2502 memcache.go:265] couldn't get current server API group list: Get "https://192.168.4.5:6443/api?timeout=32s": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
Unable to connect to the server: tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
原因:这是在重新创建集群之前,原来集群的rm -rf $HOME/.kube文件没有删除,所以导致了认证失去作用。
解决方法
方法1:
- 执行
rm -rf $HOME/.kube
删除这个路径下的文件 - 重新复制config文件:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
方法2:
执行以下操作:
echo export KUBECONFIG=/etc/kubernetes/kubelet.conf >> ~/.bashrc
source ~/.bashrc