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 查看节 ...
随机推荐
- Redis 的DB多个数据库使用
Redis 自己安装默认提供了16个数据库. 每个数据库都有一个id, 从 0 开始,(0,15). 不同的数据库中数据隔离保存.我们可以通过修改redis的配置文件进行修改数据库的数量. /etc/ ...
- Qt开发经验小技巧246-250
在编写类中有时候需要对变量进行赋值和取值,这时候一般用 setxxx.getxxx 之类的函数进行处理,而且往往里面就一行代码,这时候你可能会思考为何不直接将变量改成public暴露出来使用,还可以省 ...
- 【狂神说Java】Java零基础学习笔记-JavaSE总结
[狂神说Java]Java零基础学习笔记-JavaSE总结 JavaSE总结: -完结-撒花- [[狂神说Java]Java零基础学习视频通俗易懂]https://www.bilibili.com/v ...
- linux下VEP的安装
VEP(Variant Effect Predictor)作为Ensembl官方推出的变异影响预测软件,被广泛使用,以下内容也来自Ensembl 软件包下载(ZIP格式): curl -L-Ohttp ...
- 编译树莓派Linux内核
1.建议边看视频边跟着教程走 https://www.bilibili.com/video/av91990721?zw 2.准备工作 下载官方提供的交叉编译工具链 git clone https:// ...
- w3cschool-微信小程序开发文档-工具
微信小程序工具 概览 2020-07-22 15:24 更新 为了帮助开发者简单和高效地开发微信小程序,我们推出了全新的开发者工具,集成了开发调试.代码编辑及程序发布等功能. 扫码登录 启动工具时,开 ...
- 使用树莓派学习Linux驱动 硬件环境评估
1. 现有设备 surface,树莓派3B 简介 优点 缺点 树莓派+鼠标键盘显示屏 开发方便 需要购买小/静音键盘 需要购买显示屏 显示屏小了用着不舒服,大了太贵 树莓派不需要显示屏!将来还要刷机不 ...
- LPN问题
郁昱老师的某次讲座,记录一下! LWE和LPN: 1.LWE是模p的:噪音取自离散高斯分布 2.LPN是模2的:噪音取自伯努利分布 3.LPN很难构造同态加密方案 4.都可以分为判定型和搜索型
- delphi中unit单元文件说明
单元(unit)是组成Pascal程序的单独的源代码模块,单元有函数和过程组成,这些函数和过程能被主程序调用.一个单元至少要有unit语句,interface,和implementation三部分,也 ...
- css漂亮的弧形
我们有时会遇到要用实现一个弧形,而这样的弧形要怎么实现呢? 用图片?好像不大现实,因为这样就要无故多加载一张图片了 ,这里我们来说说怎么用css的after伪类来实现弧形. 如果想要调整弧度的话,可以 ...