kubectl 命令报错:
[root@node01 ~]# kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?

报错原因:该节点未对kubernetes进行权限配置

解决办法:
1、拷贝master01节点的/etc/kubernetes/admin.conf配置文件到/etc/kubernetes/目录下
[root@node01 ~]# scp /etc/kubernetes/admin.conf master01:/etc/kubernetes/
2、执行如下命令:
To start using your cluster, you need to run the following as a regular user:

[root@node01 ~]# mkdir -p $HOME/.kube
[root@node01 ~]# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@node01 ~]# sudo chown $(id -u):$(id -g) $HOME/.kube/config

3、配置成功
[root@node01 ~]# kubectl get nodes
NAME       STATUS   ROLES                  AGE     VERSION
master01   Ready    control-plane,master   5h47m   v1.20.6
node01     Ready    <none>                 5h36m   v1.20.6
node02     Ready    <none>                 5h36m   v1.20.6

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐