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 查看节 ...
随机推荐
- Qt/C++音视频开发66-音频变速不变调/重采样/提高音量/变速变调/倍速播放/sonic库使用
一.前言 之前在做倍速这个功能的时候,发现快速播放会有滴滴滴的破音出现,正常1倍速没有这个问题,尽管这个破音间隔很短,要放大音量才能听到,但是总归是不完美的,后面发现,通过修改qaudiooutput ...
- IM跨平台技术学习(八):新QQ桌面版为何选择Electron作为跨端框架
本文由QQ技术团队王辉.吴浩.陈俊文分享,编辑Tina整理,本文收录时有内容修订和排版优化. 1.引言 在瞬息万变的互联网行业中,年过二十四的即时通讯IM应用 QQ 堪称超长寿的产品,见证了中国互联网 ...
- Mysql连接报错排查解决记录
Mysql连接报错排查解决记录 背景: 系统:uos server-1060e 运行环境kvm虚拟机 mysql版本:5.7.44, for Linux (x86_64) 问题现象: 宿主机重 ...
- python封装https请求
1 import http.client 2 import json 3 4 class HTTPS_Connection: 5 6 def __init__(self, res_type, body ...
- 深入解析 Spring AI 系列:剖析OpenAI接口接入组件
今天我们将继续探讨如何在Spring AI中接入大语言模型,以OpenAI为例,详细分析其接入过程.我们将逐步探讨OpenAI是如何与Spring AI系统对接的,具体包括如何配置接口.如何封装接口参 ...
- 单点认证(SSO)方案调研总结
SSO方案 SSO介绍 单点登录(SSO)是一种身份验证解决方案,可让用户通过一次性用户身份验证登录多个应用程序和网站.这意味着用户只需输入一次用户名和密码,即可访问所有相互信任的系统,而无需在每个系 ...
- java设计模式---总则
设计模式总则 一.概述 1.什么是设计模式 设计模式是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结. 解释下: 分类编目:就是说可以找到一些特征去划分这些设计模式,从而进行分类. ...
- Java版的对象关系映射实现
在前面的几篇文章中,实现了获得基本类型的默认值,基本数据类型的转换等,主要的目标就是实现一个Java版的对象关系映射程序. 思路如下: 1: 对象必须是一个Java Bean. 2: 遍历对象的所有以 ...
- Educational Codeforces Round 172 (Rated for Div. 2)(C-D)
题目链接:Dashboard - Educational Codeforces Round 172 (Rated for Div. 2) - Codeforces C. Competitive Fis ...
- java中的ArrayBlockingQueue
ArrayBlockingQueue ArrayBlockingQueue 是 Java 并发包 (java.util.concurrent) 中的一个线程安全的阻塞队列实现. 它基于数组实现,容量固 ...