Minikube集群中Ingress始终错误路由流量到同一Pod的问题排查求助
Minikube集群中Ingress始终错误路由流量到同一Pod的问题排查求助
大家好,我在本地Minikube集群里搭建了三个独立租户的环境,现在遇到了Ingress路由异常的问题,想请各位帮忙排查下:
我的集群环境配置
我创建了三个独立的命名空间,每个命名空间的资源如下:
- customer-a 命名空间:
- 1个Deployment,返回内容为
"Hi from Customer A" - 1个LoadBalancer类型的Service
- 1个Ingress,绑定主机名
customer-a.example.com
- 1个Deployment,返回内容为
- customer-b 命名空间:
- 1个Deployment,返回内容为
"Hi from Customer B" - 1个LoadBalancer类型的Service
- 1个Ingress,绑定主机名
customer-b.example.com
- 1个Deployment,返回内容为
- customer-c 命名空间:
- 1个Deployment,返回内容为
"Hi from Customer C" - 1个LoadBalancer类型的Service
- 1个Ingress,绑定主机名
customer-c.example.com
- 1个Deployment,返回内容为
因为是本地Minikube集群,我通过执行 minikube tunnel 命令来暴露Ingress服务,以便外部访问。
当前资源状态
我分别查看了三个命名空间的Ingress和Service状态:
customer-a 命名空间资源
// kubectl get ing, svc -n customer-a NAME CLASS HOSTS ADDRESS PORTS AGE ingress.networking.k8s.io/customer-a nginx customer-a.example.com 80 11s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/customer-a LoadBalancer 10.96.39.62 127.0.0.1 80:30048/TCP 11s
customer-b 命名空间资源
// kubectl get ing, svc -n customer-b NAME CLASS HOSTS ADDRESS PORTS AGE ingress.networking.k8s.io/customer-b nginx customer-b.example.com 192.168.49.2 80 30s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/customer-b LoadBalancer 10.110.126.198 127.0.0.1 80:31292/TCP 30s
customer-c 命名空间资源
// kubectl get ing, svc -n customer-c NAME CLASS HOSTS ADDRESS PORTS AGE ingress.networking.k8s.io/customer-c nginx customer-c.example.com 192.168.49.2 80 6m36s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/customer-c LoadBalancer 10.104.99.195 127.0.0.1 80:32717/TCP 6m36s
我的流量区分配置
可以看到所有LoadBalancer类型的Service的EXTERNAL-IP都是127.0.0.1,所以我打算通过不同的Host头来区分流量,已经在本地/etc/hosts文件中添加了以下映射:
127.0.0.1 customer-a.example.com customer-b.example.com customer-c.example.com
遇到的问题
但实际测试时,不管我访问哪个域名,返回的结果都是Customer C的内容:
访问customer-a.example.com
// curl -kv http://customer-a.example.com > GET / HTTP/1.1 > Host: customer-a.example.com > User-Agent: curl/7.85.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < date: Thu, 29 Dec 2022 00:24:49 GMT < server: uvicorn < content-length: 20 < content-type: application/json < * Connection #0 to host customer-a.example.com left intact {"response":"Hi from Customer C"}
访问customer-b.example.com
// curl -kv http://customer-b.example.com > GET / HTTP/1.1 > Host: customer-b.example.com > User-Agent: curl/7.85.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < date: Thu, 29 Dec 2022 00:24:49 GMT < server: uvicorn < content-length: 20 < content-type: application/json < * Connection #0 to host customer-b.example.com left intact {"response":"Hi from Customer C"}
访问customer-c.example.com
// curl -kv http://customer-c.example.com > GET / HTTP/1.1 > Host: customer-c.example.com > User-Agent: curl/7.85.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < date: Thu, 29 Dec 2022 00:24:49 GMT < server: uvicorn < content-length: 20 < content-type: application/json < * Connection #0 to host customer-c.example.com left intact {"response":"Hi from Customer C"}
我猜测这个问题可能和minikube tunnel的使用有关,但不确定具体原因,有没有大佬能帮忙找出问题所在?
备注:内容来源于stack exchange,提问作者Jananath Banuka
相关产品推荐
相关产品推荐

