文章目录
The connection to the server localhost:8080 was refused - did you specify the right host or port?
问题背景
使用 kubeadm 安装完成 kubetnetes 之后,将节点加入 master 之后,提示 The connection to the server localhost:8080 was refused - did you specify the right host or port?
[root@master ~]# kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?
问题解决
方法1
查看 /etc/kubernetes/ 目录下是否存在 kubelet.conf 或者 admin.conf (个人理解只是文件名称不同),然后将上述两个文件路径写入到 /etc/profile 环境变量配置文件中
echo "/etc/kubernetes/admin.conf" >> /etc/profile
或者
echo "/etc/kubernetes/kubelet.conf" >> /etc/profile
source /etc/profile
[root@master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master NotReady control-plane,master 5m56s v1.23.0
node1 NotReady <none> 5m17s v1.23.0
node2 NotReady <none> 5m15s v1.23.0
方法2
拷贝k8s认证文件
参考官网:官网地址
官网中有对
TLS 证书错误做解答
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
# 查看节点信息,如果没有拷贝认证文件,是看不到节点信息的
kubectl get nodes

由于没有配置网络插件,所以这里看到节点信息都是 NotReady (未就绪)的
问题总结
安装参考文档:https://blog.csdn.net/D1179869625/article/details/126303213
版权声明:本文为D1179869625原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
