K8S初始化后,worker节点加了master节点,在master执行kubectl get nodes 报错,这个原因看是路径的问题导致
[root@k8s-master01 ~]# kubectl get nodes
E1114 16:28:52.032089 2254 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
E1114 16:28:52.032313 2254 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
E1114 16:28:52.033599 2254 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
E1114 16:28:52.034881 2254 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
E1114 16:28:52.036130 2254 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?
在/etc/kubernetes目录下,通过kubectl --kubeconfig命令执行,是没有问题
一个老哥告诉我修改定制kubernetes的登录权限,解决了:
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config