我正在设置一个 Istio 服务网格,其中包含两个运行 Graphql 引擎的服务。我打算将它们设置在两个不同的子路径上。您将如何在 VirtualService 上设置重定向?
我已经尝试过使用这个 VirtualService 配置
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: hasura-1
spec:
hosts:
- "*"
gateways:
- hasura-gateway
http:
- match:
- uri:
prefix: /hasura1
route:
- destination:
host: hasura-1
port:
number: 80
- match:
- uri:
prefix: /hasura2
route:
- destination:
host: hasura-2
port:
number: 80
但是每当我尝试访问这些前缀时,我都会遇到错误 404。
编辑:我已经更新了我的虚拟服务以合并rewrite.uri
. 每当我尝试访问任一前缀时,我都会被重定向到/
并给出错误 404。这是我更新的网关和 VirtualService 清单。
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: hasura-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: hasura-1
spec:
hosts:
- "*"
gateways:
- hasura-gateway
http:
- match:
- uri:
exact: /hasura1
rewrite:
uri: /
route:
- destination:
host: hasura-1
port:
number: 80
- match:
- uri:
exact: /hasura2
rewrite:
uri: /
route:
- destination:
host: hasura-2
port:
number: 80
---