kubernetes - GKE 1.10 kubernetes 集群上的网络连接/DNS 问题
问题描述
我在 GKE 1.10 kubernetes 集群上遇到了 DNS 问题。有时 pod 在没有任何网络连接的情况下启动。重新启动 pod 往往会解决问题。
这是没有网络的容器中相同的几个命令的结果,一个有。
破碎的:
kc exec -it -n iotest app1-b67598997-p9lqk -c userapp sh
/app $ nslookup www.google.com
nslookup: can't resolve '(null)': Name does not resolve
/app $ cat /etc/resolv.conf
nameserver 10.63.240.10
search iotest.svc.cluster.local svc.cluster.local cluster.local c.myproj.internal google.internal
options ndots:5
/app $ curl -I 10.63.240.10
curl: (7) Failed to connect to 10.63.240.10 port 80: Connection refused
/app $ netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8001 0.0.0.0:* LISTEN 1/python
tcp 0 0 ::1:50051 :::* LISTEN 1/python
tcp 0 0 ::ffff:127.0.0.1:50051 :::* LISTEN 1/python
在职的:
kc exec -it -n iotest app1-7d985bfd7b-h5dbr -c userapp sh
/app $ nslookup www.google.com
nslookup: can't resolve '(null)': Name does not resolve
Name: www.google.com
Address 1: 74.125.206.147 wk-in-f147.1e100.net
Address 2: 74.125.206.105 wk-in-f105.1e100.net
Address 3: 74.125.206.99 wk-in-f99.1e100.net
Address 4: 74.125.206.104 wk-in-f104.1e100.net
Address 5: 74.125.206.106 wk-in-f106.1e100.net
Address 6: 74.125.206.103 wk-in-f103.1e100.net
Address 7: 2a00:1450:400c:c04::68 wk-in-x68.1e100.net
/app $ cat /etc/resolv.conf
nameserver 10.63.240.10
search iotest.svc.cluster.local svc.cluster.local cluster.local c.myproj.internal google.internal
options ndots:5
/app $ curl -I 10.63.240.10
HTTP/1.1 404 Not Found
date: Sun, 29 Jul 2018 15:13:47 GMT
server: envoy
content-length: 0
/app $ netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:15000 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:15001 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8001 0.0.0.0:* LISTEN 1/python
tcp 0 0 10.60.2.6:56508 10.60.48.22:9091 ESTABLISHED -
tcp 0 0 127.0.0.1:57768 127.0.0.1:50051 ESTABLISHED -
tcp 0 0 10.60.2.6:43334 10.63.255.44:15011 ESTABLISHED -
tcp 0 0 10.60.2.6:15001 10.60.45.26:57160 ESTABLISHED -
tcp 0 0 10.60.2.6:48946 10.60.45.28:9091 ESTABLISHED -
tcp 0 0 127.0.0.1:49804 127.0.0.1:50051 ESTABLISHED -
tcp 0 0 ::1:50051 :::* LISTEN 1/python
tcp 0 0 ::ffff:127.0.0.1:50051 :::* LISTEN 1/python
tcp 0 0 ::ffff:127.0.0.1:50051 ::ffff:127.0.0.1:49804 ESTABLISHED 1/python
tcp 0 0 ::ffff:127.0.0.1:50051 ::ffff:127.0.0.1:57768 ESTABLISHED 1/python
这些 pod 是相同的,只是重新启动了一个。
有人对如何分析和解决此问题有建议吗?
解决方案
一些尝试的步骤:
1) ifconfig eth0 或任何主接口。界面开了吗?tx 和 rx 数据包计数是否在增加?
2)如果接口已启动,您可以在运行您发布的 nslookup 命令时尝试 tcpdump。查看是否发送了 dns 请求数据包。
3) 当网络连接中断时,查看 pod 被安排在哪个节点上。也许它每次都在同一个节点上?如果是,该节点上的其他 pod 是否也遇到类似问题?
推荐阅读
- c++ - 构建 dll 文件也会在我的环境中构建 .lib
- angular - 在内容子项之间添加分隔符
- assistant - 为什么 Google Assistant 无法朗读某些页面?
- xaml - 如何使 .xaml 文件中的文本包含蜜蜂电影?
- python - NameError:未定义名称“bmi_calculator”
- cloud - 新交所运行了多少代码?没有任何限制吗?
- android - 从 XML 中的 SVG 字符串创建路径
- php - 在使用 200 万行以上的数据库表时,有什么方法可以优化查询
- java - 虽然循环没有在 Java 中爆发
- rx-java - IdlingResource Espresso 与 RxJava3