重启k8s集群之后,node节点无法使用kubectl命令

root@node2 \~\]# kubectl get nodes E0821 22:25:19.750964 17313 memcache.go:265\] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp \[::1\]:8080: connect: connection refused E0821 22:25:19.752102 17313 memcache.go:265\] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp \[::1\]:8080: connect: connection refused

解决方法:在不能运行的节点上执行以下命令

复制代码
[root@node2 ~]# echo "export KUBECONFIG=/etc/kubernetes/kubelet.conf" >> /etc/profile
[root@node2 ~]# source /etc/profile

[root@node2 ~]# kubectl get nodes
NAME     STATUS   ROLES           AGE   VERSION
master   Ready    control-plane   31h   v1.28.15
node1    Ready    <none>          30h   v1.28.15
node2    Ready    <none>          30h   v1.28.15

成功!!!