![cover](https://img-blog.csdnimg.cn/img_convert/60b04f0c92ee49ecb12bfea536f61927.png)
k8s重启报错:Get “http://localhost:8080/api?timeout=32s“: dial tcp [::1]:8080: connect: connection refuse
单从报错可以看出,kubectl 没有使用到证书与k8s api通信,在初始化集群的时候要想使用kubectl需要,申明证书变量 export KUBECONFIG=/etc/kubernetes/admin.conf ,重启之后 KUBECONFIG 变量失效了。所有需要重新声明,并加入过/etc/profile 全局变量文件。
·
[root@k8s-master ~]# kubectl get nodes
E0322 10:29:10.166586 8455 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
E0322 10:29:10.166882 8455 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
E0322 10:29:10.168298 8455 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
E0322 10:29:10.170502 8455 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
E0322 10:29:10.172351 8455 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 没有使用到证书与k8s api通信,在初始化集群的时候要想使用kubectl需要,申明证书变量 export KUBECONFIG=/etc/kubernetes/admin.conf ,重启之后 KUBECONFIG 变量失效了。所有需要重新声明,并加入过/etc/profile 全局变量文件。
echo "export KUBECONFIG=/etc/kubernetes/kubelet.conf" >> /etc/profile
source /etc/profile
[root@k8s-master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane 15m v1.28.2
更多推荐
所有评论(0)