栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

[云原生专题-27]:K8S - 问题解决 - The connection to the server localhost:8080 was refused - did you specify

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

[云原生专题-27]:K8S - 问题解决 - The connection to the server localhost:8080 was refused - did you specify

1. 现象:

安装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?

2. 原因分析

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
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/724828.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号