【发布时间】:2021-12-29 02:51:08
【问题描述】:
我有两个不同的微服务在同一个命名空间中运行,它们都有相同的上下文路径(例如 - my/context/path),进一步的控制器在它们中是不同的,例如服务一支持 - my/context/ path/service1 和 service2 支持 my/context/path/service2 现在当我像这样定义vs时,它总是重定向到service1,有没有可能的方法来实现这一点? 下面是我的VS:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: test-service
namespace: ns-ns
spec:
gateways:
- gateway.ns-ns
hosts:
- '*'
http:
- match:
- uri:
prefix: /my/context/path
route:
- destination:
host: service1.ns-ns.svc.cluster.local
port:
number: 9000
- route:
- destination:
host: service2.ns-ns.svc.cluster.local
port:
number: 9000
我也在VS下面尝试过,但这似乎也重定向到第一个服务。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: test-service
namespace: ns-ns
spec:
gateways:
- gateway.ns-ns
hosts:
- '*'
http:
- match:
- uri:
prefix: /my/context/path
route:
- destination:
host: service1.ns-ns.svc.cluster.local
port:
number: 9000
- match:
- uri:
prefix: /my/context/path/service2
route:
- destination:
host: service2.ns-ns.svc.cluster.local
port:
number: 9000
我不确定这是否可以实现,或者我是否需要将两个服务的上下文部分分开?
【问题讨论】:
标签: kubernetes microservices istio istio-gateway istio-operator