k8s节点node报错The connection to the server localhost:8080 was refused - did you specify the right host or port?
解决办法:
将master节点上的admin.conf文件拷贝到从节点
1在master节点上执行传文件
[root@master ~]# scp /etc/kubernetes/admin.conf node2:/etc/kubernetes/
Password:
admin.conf 100% 5562 4.8MB/s 00:00
[root@master ~]# scp /etc/kubernetes/admin.conf node1:/etc/kubernetes/
Password:
admin.conf 100% 5562 2.1MB/s 00:00
2在node节点上执行配置环境变量:
[root@node1 ~]# vim /etc/profile
[root@node1 ~]# tail -n1 /etc/profile
export KUBECONFIG=/etc/kubernetes/admin.conf
[root@node1 ~]# source /etc/profile
[root@node1 ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
master Ready master 18d v1.19.3
node1 Ready <none> 18d v1.19.3
node2 Ready <none> 18d v1.19.3
3在node的节点上查看
[root@node1 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION master Ready master 3d4h v1.19.3 node1 Ready <none> 3d2h v1.19.3 node2 Ready <none> 3d2h v1.19.3