前言

k8s 集群 node节点报错:The connection to the server localhost:8080 was refused - did you specify the right host or port?

通过 kubectl get nodes 查看集群的情况,出现了报错,内容如下:

$ kubectl get pod
E0529 02:28:59.776677 415799 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E0529 02:28:59.777439 415799 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E0529 02:28:59.778983 415799 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E0529 02:28:59.780888 415799 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E0529 02:28:59.782303 415799 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
The connection to the server localhost:8080 was refused - did you specify the right host or port?

原因:

kubectl 默认从 ~/.kube/config 配置文件获取访问 kube-apiserver 地址、证书、用户名等信息,如果没有配置该文件会读取默值,即 localhost:8080,而本机的 localhost:8080 没有服务因而报 The connection to the server localhost:8080 was refused - did you specify the right host or port?

解决

先检查当前 kubectl 配置加载信息,kubectl config view,如果为空需要检查 /etc/kubernetes/admin.conf 配置文件和 $HOME/.kube/config 配置,如果不存在,需要复制master节点上的配置到当前节点上

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config Alternatively, if you are the root user, you can run: export KUBECONFIG=/etc/kubernetes/admin.conf

指定配置文件路径

如果你的配置文件不在默认路径,可以通过 KUBECONFIG 环境变量指定路径,或者在命令行中使用 --kubeconfig 选项。

使用 KUBECONFIG 环境变量

export KUBECONFIG=/path/to/your/kubeconfig
kubectl config view

使用 --kubeconfig 选项

 kubectl --kubeconfig=/etc/kubernetes/admin.conf config view

k8s:The connection to the server localhost:8080 was refused - did you specify the right host or port?的更多相关文章

  1. 使用二进制方式安装K8S时使用kubectl命令报错:The connection to the server localhost:8080 was refused - did you specify the right host or port?

    解决思路: kubectl 默认从 ~/.kube/config 配置文件获取访问 kube-apiserver 地址.证书.用户名等信息,如果没有配置该文件,或者该文件个别参数配置出错,执行命令时出 ...

  2. The connection to the server localhost:8080 was refused - did you specify the right host or port?

    The connection to the server localhost:8080 was refused - did you specify the right host or port? 解决 ...

  3. kubernetes 报错The connection to the server localhost:8080 was refused - did you specify the right host or port?

    The connection to the server localhost:8080 was refused - did you specify the right host or port? 环境 ...

  4. Kubernetes-kubectl The connection to the server localhost:8080 was refused -did you specify

    今天在Kubernetes的从节点上运行命令[kubectl]出现了如下错误: [root@k8snode1 kubernetes]# kubectl get pod The connection t ...

  5. 【Kubernetes】The connection to the server <master>:6443 was refused - did you specify the right host or port?

    不知道怎么用着用着,使用kubectl 时报错,错误如下: root@R740--:~# kubectl get pod The connection to the server 107.105.13 ...

  6. kubectl error: The connection to the server localhost:8080 was refused

    did you run below commands after kubeadm init To start using your cluster, you need to run (as a reg ...

  7. k8s节点执行master命令报错 localhost:8080 was refused

    首先是按照二进制方式安装的k8s. [root@ht22 calico]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) [ ...

  8. 虚拟机中MySQL连接问题:Lost connection to MySQL server at 'reading initial communication packet, system error: 0 以及 host is not allowed to connect mysql

    环境:在VirtualBox中安装了Ubuntu虚拟机,网络使用了NAT模式,开启了端口转发. 局域网内其他计算机访问虚拟机中的MySQL Server出现两个问题: Lost connection ...

  9. k8s遇坑:The connection to the server k8s-api.virtual.local:6443 was refused - did you specify the right host or port?

    k8s坑The connection to the server localhost:8080 was refused - did you specify the right host or port ...

  10. K8s - 解决主机重启后kubelet无法自动启动问题 错误:The connection to the server 192.168.60.128:6443 was refused - did you specify the right host or port?

    1,问题描述 (1)在安装配置好 Kubernetes 后,正常情况下服务器关机重启,kubelet 也会自动启动的.但最近配置的一台服务器重启后,输入命令 kubectl get nodes 查看节 ...

随机推荐

  1. 11.15javaweb学习

  2. Eclipse中如何将web应用部署到tomcat

    第1种方法: 将workspace下的复制到tomcat的webapp下(我看度还是算了,看着都觉得麻烦). 第2种方法:总体思路就是:(1)先为web应用创建Tomcat Server:(2)再将w ...

  3. Ubuntu安装宝塔服务

    Linux面板7.9.4安装脚本 查看详细安装教程 使用 SSH 连接工具,如 堡塔SSH终端 连接到您的 Linux 服务器后, 挂载磁盘 ,根据系统执行相应命令开始安装(大约2分钟完成面板安装): ...

  4. Solution Set -「NOIP Simu.」20221111

    \(\mathscr{A}\sim\) 遗忘十字路   Cover:「CF 1746D」Paths on the Tree.   Tag:「C.性质/结论」   最原始的思路自然是 DP. 令 \(f ...

  5. 字体查看比较工具 -- (采用wpf开发)

    为了进一步加深对字体文件的理解,我写了这个小工具.可以查看字体文件信息.显示字体文件包含的字体.可以从字体文件中抽取字体,保存为其子集. 加入qq群:565438497,下载最新程序. 1 显示字体文 ...

  6. JAVA调用groovy脚本的方式

    一.使用用 Groovy 的 GroovyClassLoader ,它会动态地加载一个脚本并执行它.GroovyClassLoader是一个Groovy定制的类装载器,负责解析加载Java类中用到的G ...

  7. 【Netty】(5)-源码 Bootstrap

    [Netty]5 源码 Bootstrap 上一篇讲了AbstractBootstrap,为这篇做了个铺垫. 一.概述 Bootstrap 是 Netty 提供的一个便利的工厂类, 我们可以通过它来完 ...

  8. 项目PMP之六项目进度管理

    项目PMP之六--项目进度管理   一.定义:用于沟通和管理相关方期望的工具,可作为报告绩效的基础,说明项目的交付时间和方式 迭代型进度计划(敏捷模式):接受存在未完成项,滚动式规划管理 按需进度计划 ...

  9. Spring Boot前后端分离直接访问静态页+ajax实现动态网页

    Spring Boot前后端分离直接访问静态页+ajax实现动态网页. 一般java里面Spring Boot项目的静态资源resources/下面有两个文件夹和一个配置文件,分别是static/目录 ...

  10. Linux 文件压缩和解压缩命令

    Linux 文件压缩和解压缩命令 在Linux操作系统中,文件压缩和解压缩是日常管理和维护任务中的重要一环.通过压缩文件,可以显著减少存储空间的使用,并加快网络传输速度.Linux提供了多种压缩和解压 ...