kubectl 报错 couldn‘t get current server API group list:
🔍场景一:刚搭建完成k8s集群,查看pod报如下错
[root@node02 ~]# kubectl get pod
E0218 10:58:33.139354 37437 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
E0218 10:58:33.140227 37437 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
E0218 10:58:33.143318 37437 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
E0218 10:58:33.145017 37437 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
E0218 10:58:33.147309 37437 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
The connection to the server localhost:8080 was refused - did you specify the right host or port?
✅解决方法:准备kubectl 配置文件
在master节点上操作
mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/config
🔍场景二:集群搭建完成,但关机后,查看pod 报如下错
报错信息:
E0914 11:51:02.84256214052 memcache.go:265]"Unhandled Error"'couldn't get current server API group list: Get \"https://192.168.00,10:6443/api?timeout=32s\": dial tcp 192.168.100.10:6443: conneerct: connection refused
✅解决方步骤
1.检查kubelet服务是否运行2.docker ps -a 查看k8s-etcd容器是否关闭3.尝试启动etcd容器,并重启kubectl 服务
4.若还不行,则启动api server 容器再试