通过 k8s 访问 service 的 cluster-ip 特别慢可能是怎么回事?

2020-02-17 15:53:25 +08:00
 wd

集群是 1 master, 1 node。有一个 pod,rep 是 1,这个时候会在那个 node 上面跑起来,expose 一个 service 之后,会有一个 cluster-ip,在跑 pod 的那个 node 上面访问是通的,在 master 上面也可以通,但是特别慢。

 $ time curl 10.99.31.78
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.17.8</center>
</body>
</html>

real    1m3.141s
user    0m0.003s
sys     0m0.004s

我试过直接请求对应 pod 的 ip,是很快的

$ time curl 10.244.1.2:8090
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.17.8</center>
</body>
</html>

real    0m0.006s
user    0m0.002s
sys     0m0.003s

这个可能是啥原因呢?感觉是某个服务出问题了,在等着超时。。。。。

6047 次点击
所在节点    Kubernetes
2 条回复
wd
2020-02-17 15:55:37 +08:00
看了一下 kube-system 的 pod 的日志,好像没看到什么错误

```
coredns-6955765f44-jcd6l 1/1 Running 0 20h
coredns-6955765f44-qmdb8 1/1 Running 0 20h
etcd-master 1/1 Running 0 20h
kube-apiserver-master 1/1 Running 0 20h
kube-controller-manager-master 1/1 Running 0 20h
kube-flannel-ds-amd64-m5lnz 1/1 Running 0 19h
kube-flannel-ds-amd64-rljp6 1/1 Running 0 19h
kube-proxy-ddrlh 1/1 Running 0 19h
kube-proxy-zrppq 1/1 Running 0 20h
kube-scheduler-master 1/1 Running 0 20h
```
wd
2020-02-17 16:02:47 +08:00
使用 `ip route add 10.99.0.0/16 dev flannel.1` 加了一条路由就好了,很奇怪。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/645262

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX