k8s:The connection to the server localhost:8080 was refused - did you specify the right host or port?
前言
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?的更多相关文章
- 使用二进制方式安装K8S时使用kubectl命令报错:The connection to the server localhost:8080 was refused - did you specify the right host or port?
解决思路: kubectl 默认从 ~/.kube/config 配置文件获取访问 kube-apiserver 地址.证书.用户名等信息,如果没有配置该文件,或者该文件个别参数配置出错,执行命令时出 ...
- 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? 解决 ...
- 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? 环境 ...
- 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 ...
- 【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 ...
- 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 ...
- k8s节点执行master命令报错 localhost:8080 was refused
首先是按照二进制方式安装的k8s. [root@ht22 calico]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) [ ...
- 虚拟机中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 ...
- 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 ...
- 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 查看节 ...
随机推荐
- Vue3使用Vuex 教程(这才是真正的小白教程!)
我的项目是vue3+element-plus 我是个菜鸡,我不懂前端.想做一个tags的导航标签页.但是点击标签页之后页面仍然是会重新请求.感觉这不就跟没做一样吗? 遂百度GPT,第一种方式采用的就是 ...
- [转]Bundle Adjustment简述
原文链接:https://optsolution.github.io/archives/58892.html或https://blog.csdn.net/optsolution/article/det ...
- vue引入element-ui插件 “export ‘default‘ (imported as ‘Vue‘) was not found in ‘vue‘
注意:出现该问题的原因主要是使用的Vue版本与Element-UI的版本不匹配. Vue.Vue-cli与Element-UI之间版本的正确的匹配关系是: Vue库版本 Vue-cli库版本 Elem ...
- [LC814]二叉树剪枝
题目 题目地址 分析 这道题符合递归的性质,对于当前的节点node,当且仅当其左右孩子都为不包含1的子树,且node.val=1时,node所在的子树才符合"不包含1的子树"这一定 ...
- Python调用ChatTTS API接口
Python调用ChatTTS API接口: #********************************************* #author:wgscd #date:2024-7-27 ...
- runoob-scipy(python)
https://www.runoob.com/scipy/scipy-tutorial.html SciPy 教程 SciPy 是一个开源的 Python 算法库和数学工具包. Scipy 是基于 N ...
- MySQL---索引、Explain、优化、慢查询
索引 什么是索引? 索引是帮助Mysql提高获取数据的数据结构,换一句话讲就是"排好序的快速查找的数据结构". 一.索引的分类 MySQL主要的几种索引类型:1.普通索引.2.唯 ...
- 告别虚拟机!WSL2安装配置教程!!!
作者:SkyXZ CSDN:SkyXZ--CSDN博客 博客园:SkyXZ - 博客园 由于Linux的系统的稳定以及在环境管理方面的优越性,同时Linux对于ROS系统的独占,很多时候我们都乐意在L ...
- hackmyvm靶机拯救者模式解决分配不到ip的问题 转载
https://www.cnblogs.com/jason-huawen/p/16851113.html https://www.cnblogs.com/asstart/p/12626494.html ...
- frida 解决一些报错问题
遇到的一些问题 第一个问题 Unable to start: Error binding to address 127.0.0.1:27042: Address already in use 解决方法 ...