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的异常,其实解决方法很简单。
1609 0
The telnet port 3658 is used by process
|
5天前
|
网络协议 关系型数据库 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
|
13天前
|
网络安全
阿里云Could not connect to SITP host: smtp.163.com,port: 25;
阿里云Could not connect to SITP host: smtp.163.com,port: 25;
16 1
|
2月前
|
分布式计算 Hadoop 网络安全
[m1pro ] ssh: connect to host localhost port 22: Connection refused
[m1pro ] ssh: connect to host localhost port 22: Connection refused
|
2月前
|
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
|
2月前
|
网络协议 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
195 0
|
9月前
|
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
|
网络安全
错误集--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)
1334 0
错误集--NFS报错clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
|
11月前
|
网络协议 Linux 网络安全
使用frp时遇到的问题connect: connection refuseddial tcp xxxx:7000: connect: connection refused
最近在做的项目需要用到frp来做代理连接本地内网机,卡在最后启动客户端的时候,提示报错:login to server failed: dial tcp xxxx:7000: connect: connection refuseddial tcp xxxx:7000: connect: connection refused!!找了很多尝试的办法,现在给大家列一下希望对大家有帮助。
2178 0