我在 Istio VirtualService 配置中遇到有关重复/重叠匹配的警告消息,我正在寻求解决该问题的帮助。这是警告消息:
Warning: virtualService rule #1 match #0 of prefix /apparchived/ is not used (duplicate/overlapping match in rule #1 of prefix /app on #0)
我有一个 VirtualService 配置,需要将路径 /app 和 /apparchived 的请求路由到不同的服务,同时保留 URI 路径。但是,我的配置中遇到了重叠匹配的问题。
这是我当前的 VirtualService 配置:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: app
namespace: ingress-routes
spec:
hosts:
- "*"
gateways:
- dev-app-gateway
http:
- match:
- uri:
prefix: "/app/"
- uri:
prefix: "/app"
rewrite:
uri: "/"
route:
- destination:
host: app.app.svc.cluster.local
port:
number: 80
- match:
- uri:
prefix: "/apparchived/"
- uri:
prefix: "/apparchived"
rewrite:
uri: "/"
route:
- destination:
host: apparchived.app.svc.cluster.locala
number: 80
我想实现以下路由行为:
谢谢!
请使用“精确”和“前缀”属性组合来实现您正在寻找的所需路由。请使用下面的虚拟服务定义以避免“规则警告中的重复/重叠匹配”
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: app
namespace: ingress-routes
spec:
hosts:
- "*"
gateways:
- dev-app-gateway
http:
- match:
- uri:
prefix: "/app/"
- uri:
exact: "/app"
rewrite:
uri: "/"
route:
- destination:
host: app.app.svc.cluster.local
port:
number: 80
- match:
- uri:
prefix: "/apparchived/"
- uri:
exact: "/apparchived"
rewrite:
uri: "/"
route:
- destination:
host: apparchived.app.svc.cluster.local
number: 80