kubectl命令报错:Unable to connect to the server: dial tcp XXX:16443: connect: no route to host

简介: kubectl命令报错:Unable to connect to the server: dial tcp XXX:16443: connect: no route to host

前提

架构:keepalived+haproxy+kubernetes


问题说明

kubernetes集群好久不用了,今天打开集群执行一个kubectl get nodes命令,报错如下:

Unable to connect to the server: dial tcp 192.168.2.XXX:16443: connect: no route to host


分析原因

出现这个问题几种原因,

  1. 集群坏了:如果报错的IP是master1的节点IP或虚拟IP(vip)加16443端口号,执行kubectl命令还报上面的错误,说明集群坏了,需要逐步排查原因。
  2. /root/.kube/config中的IP地址错误:如果错误中的IP地址不是master1的节点IP或虚拟IP(vip)加16443端口号,需要修改配置文件中的IP。一般改为虚拟IP(vip)+16443端口号。
  3. haproxy:由于haproxy配置的是监听16443端口,也是集群的入口。因为报错的端口号是16443,所以要检查是否是haproxy的IP问题,如果是的话要修改haproxy配置文件,然后重启haproxysystemctl restart haproxy


解决问题

经排查,我的问题属于第二种,因为报错的意思是没有找不到192.168.2.XXX:16443这个路由,于是检查config文件:

vim /root/.kube/config


查看IP是否正确,经检查,我虚拟IP为:192.168.2.249,而这里显然不是,将IP修改为192.168.2.249:16443

892ee2b773a5462cbad25e4083c4c297.png

保存退出后再次查看节点状态,kubectl命令就可以正常使用了。

bda88e6ec2cf4a329afa07bdb2aa410a.png

另一中错误:Unable to connect to the server: dial tcp 123.56.91.155:6443: i/o timeout

Unable to connect to the server: dial tcp 123.56.91.155:6443: i/o timeout

刚开始爆出的错误是这个,一看这个IP就不是我当初创建集群时的IP,而是一个阿里云公网IP,其实进入config文件中修改成自己集群的IP就可以了。

相关文章
|
Arthas 测试技术 网络安全
The telnet port 3658 is used by process
是否在本地使用Arthas的时候,遇到The telnet port 3658 is used by process 34725 instead of target process 44848, you will connect to an unexpected process的异常,其实解决方法很简单。
2041 0
The telnet port 3658 is used by process
|
3月前
|
网络协议 Shell 网络安全
ssh: connect to host github.com port 22: Connection refused
本文讨论了在使用Git命令操作GitHub时遇到的"ssh: connect to host github.com port 22: Connection refused"错误,分析了可能的原因,并提供了使用443端口或https协议作为解决方案,最终确定问题是由于DNS解析错误导致,通过修改hosts文件解决。
ssh: connect to host github.com port 22: Connection refused
|
4月前
|
网络协议 关系型数据库 MySQL
启动mysql时的异常为:[ERROR] Can‘t start server: Bind on TCP/IP port. Got error: 98: Address already in used
启动mysql时的异常为:[ERROR] Can‘t start server: Bind on TCP/IP port. Got error: 98: Address already in used
|
4月前
|
应用服务中间件 nginx Docker
connect() failed (113: No route to host) while connecting to upstream
connect() failed (113: No route to host) while connecting to upstream
149 0
|
6月前
|
分布式计算 Hadoop 网络安全
[m1pro ] ssh: connect to host localhost port 22: Connection refused
[m1pro ] ssh: connect to host localhost port 22: Connection refused
|
6月前
|
Kubernetes Perl 容器
k8s创建完pod后报错: Failed connect to 10.244.36.90:8000; No route to host
k8s创建完pod后报错: Failed connect to 10.244.36.90:8000; No route to host
154 0
|
6月前
|
网络协议 NoSQL Redis
解决 Error starting userland proxy: listen tcp 0.0.0.0:6379: bind: address already in use
解决 Error starting userland proxy: listen tcp 0.0.0.0:6379: bind: address already in use
329 0
|
网络安全
错误集--NFS报错clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
错误集--NFS报错clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
1531 0
错误集--NFS报错clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
|
Linux 网络安全
ssh: connect to host 10.13.69.163 port 22: No route to host
ssh: connect to host 10.13.69.163 port 22: No route to host
|
数据安全/隐私保护
记录curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused解决方案
关于这个错误其实遇到过好多次了,基本都是在每次换电脑之后执行
记录curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused解决方案