首页 > 其他分享 >k8s:The connection to the server localhost:8080 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

时间:2024-05-29 11:21:57浏览次数:9  
标签:right 8080 get did refused connection server localhost

前言

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?

解决

先检查当前 kubelct 配置加载信息,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

标签:right,8080,get,did,refused,connection,server,localhost
From: https://www.cnblogs.com/niuben/p/18219822

相关文章

  • 《最新出炉》系列入门篇-Python+Playwright自动化测试-49-Route类拦截修改请求-下篇
    1.简介 在日常工作和学习中,自动化测试的时候:在加载页面时,可能页面出现很多不是很重要或者不是我们所关注的,这个时候我们就可以选择不加载这些内容,以提高页面加载速度,节省资源。例如:可能页面上图片比较多,而我们又不关心图片内容。那么,在加载页面时,可以选择不加载图片,以提高页面加......
  • 《最新出炉》系列入门篇-Python+Playwright自动化测试-47-自动滚动到元素出现的位置
    1.简介在我们日常工作中或者生活中,经常会遇到我们的页面内容较多,一个屏幕范围无法完整展示内容,我们就需要滚动滚动条去到我们想要的地方,如下图页面,我们虽然在豆瓣首页,但是内容并不完整,如果我们想要直接点击电影模块中的选电影按钮,是需要往下滑动的。当页面超过屏幕的高度时候,需要......
  • Nodejs Playwright 2Captcha 验证码识别实现自动登陆
    NodejsPlaywright2Captcha验证码识别实现自动登陆需求日常工作当中,为了提高工作效率,我们可能会写脚本来自动执行任务。有些网站因为需要用户登陆,所以脚本的自动登陆功能必不可少。不过我们在登陆网站的时候经常会出现验证码,验证码的目的就是为了防止机器登陆、自动化脚本操......
  • join、inner join、left join、right join、outer join的区别
    什么是联结?union、intersect等集合运算,它的特征是以“行”为单位进行操作,通俗点说,就是进行这些集合运算,会导致记录行数的增减,使用union会增加记录行数,使用intersect或expect会减少行记录,集合运算不会导致“列”数量的改变。而联结(join)操作,就是将其他表中的列添加过来,进......
  • 使用playwright控制浏览器在服务器端将网页转化为PDF文件
    需求在实际需要中,经常存在需要在服务器端将网页转化为PDF文件保存下来。代码requirements.txt点击查看代码playwrightconvert_pdf.py点击查看代码fromplaywright.sync_apiimportsync_playwright,Playwrightimportargparsedefrun(playwright:Playwright,url......
  • 比Selenium更优秀的playwright介绍与未来展望
    Playwright是微软开发的,专门为满足端到端测试需求而创建的。Playwright支持包括Chromium、WebKit和Firefox在内的所有现代渲染引擎。在Windows、Linux和macOS上进行测试,本地或在CI上,无头或有头,带有本机移动仿真。安装安装playwright库pipinstall--upgradepippipinstall......
  • 零操作,高效下载:利用Playwright和Python完成文件下载
    前言Playwright是一个由Microsoft开发的跨浏览器自动化测试工具,它提供了强大的功能来模拟用户在浏览器中的操作。Playwright还可以应用于诸如文件下载等实际场景的测试。本文将介绍如何利用Playwright在Python中实现文件下载功能。文件下载文件下载也是我们进行web自......
  • Playwright执行 JavaScript 脚本:探索浏览器自动化的新境界
    前言我们在进行web自动化时,经常遇到一些不好操作的元素,普通的元素定位和操作容易报错,如果我们使用的selenium的话,就可以使用selenium调用js脚本进行操作。在playwright中也有类似的方法,使用page.evaluate()执行JavaScript脚本。page.evaluate()和page.evaluate_handle()之间的......
  • 使用 Playwright 复用 Cookie:简化自动化测试的高效方法
    前言在进行自动化测试时,有时需要在多个测试用例之间共享相同的会话状态。为了实现这一目标,Playwright提供了一种称为Cookie复用的功能,可以让我们在不同的测试用例之间共享同一组Cookie数据。本文将深入介绍如何使用Playwright复用Cookie,并探讨其使用方法和优势。什么是......
  • 无需手动操作:利用 Playwright 自动上传文件
    前言Playwright是一个由Microsoft开发的自动化测试工具,它提供了跨浏览器的自动化测试能力,包括Chrome、Firefox和Safari。除了测试之外,Playwright还可以用于执行浏览器操作,例如模拟用户行为来实现文件上传功能。在本文中,我们将使用Playwright和Python实现自动上传文件......