我已经通过一个简单的http网关运行了一个VirtualService,一切正常:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: satc-gateway
spec:
selector:
istio: ingressgateway # use istio default controller
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: report
spec:
hosts:
- report-create.default.svc.cluster.local
gateways:
- satc-gateway
http:
- match:
- uri:
prefix: /v1/report
route:
- destination:
host: report-create
port:
number: 8080
此后,我通过同一网关为群集中的第二个服务添加了第二个虚拟服务
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: routing
spec:
hosts:
- routing-svc.default.svc.cluster.local
gateways:
- satc-gateway
http:
- match:
- uri:
prefix: /v1/routing
route:
- destination:
host: routing-svc.default.svc.cluster.local
port:
protcol: http
number: 8080
虽然第一个VirtualService似乎仍在服务,但第二个始终如一的404。我添加了一个简单的端点"/v1/routing/test"
来返回 Hello World 消息,以确保问题不会从应用程序逻辑中生成。
这两个虚拟服务似乎都按预期运行,尽管只有对report
的请求返回 404 以外的任何内容:
report [satc-gateway] [report-create.default.svc.cluster.local] 2h
routing [satc-gateway] [routing-svc.default.svc.cluster.local] 18m
我尝试一起删除第一个部署,以确保它现在正在收集进入集群的所有流量,并且仍然得到 404。我还尝试从 pod 内部执行路由并成功响应,这两个服务都使用容器端口 8080,我也对其进行了三重检查。
我似乎对此有点困难,不确定为了正确调试的下一个最佳步骤是什么。
我已经分析了您的两个yamls,并发现了有关第二个的几个问题:
prefix:
行中有 2 个额外的空格- "协议:"行中有一个拼写错误(错过了
o
( destination:
部分存在一些差异
请进行调整,并让我知道是否有帮助。