安装K8S mananger后,执行kubectl get nodes始终出错
[root@k8s-master1 sysctl.d]# kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?
kubernetes master没有与本机绑定,集群初始化的时候没有绑定,导致kubectl 无法识别master是自身。
3. 解决之道此时设置在本机的环境变量即可解决问题。
4. 解决过程 步骤一:设置环境变量具体根据情况,此处记录linux设置该环境变量 方式一:编辑文件设置 vim /etc/profile 在底部增加新的环境变量 export KUBEConFIG=/etc/kubernetes/admin.conf 方式二:直接追加文件内容 echo "export KUBEConFIG=/etc/kubernetes/admin.conf" >> /etc/profile步骤二:使生效
source /etc/profile步骤三:验证
[root@k8s-master1 sysctl.d]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-master1 Ready control-plane,master 4m35s v1.23.3


![[云原生专题-27]:K8S - 问题解决 - The connection to the server localhost:8080 was refused - did you specify [云原生专题-27]:K8S - 问题解决 - The connection to the server localhost:8080 was refused - did you specify](http://www.mshxw.com/aiimages/31/724828.png)
