istio - 是否可以在虚拟服务定义中组合 AND 和 OR 匹配?
问题描述
我正在尝试在 Istio (1.3.3) 中定义一个虚拟服务,它有多个匹配项,但在匹配项中,应该有 OR 功能。
例如:(伪代码)
match
header-key = value1
OR header-key = value2
OR header-key = value3
OR ....
OR header-key = value100
AND
match
uri-prefix = prefix1
OR uri-prefix = prefix2
OR uri-prefix = prefix3
OR uri-prefix = ...
OR uri-prefix = prefix100
因此,对于每个 AND 块,应该至少有一个匹配的 OR 条件。
我已经尝试过匹配,但是如果满足所有条件中的 1 个,那么它是有效的,但我想要的是匹配 API 密钥之一并匹配 URI 前缀之一。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: test
namespace: demo
spec:
hosts:
- test1
gateways:
- test-gateway
http:
- match:
- headers:
apikey:
exact: 111
- headers:
apikey:
exact: 222
- headers:
apikey:
exact: 333
- uri:
prefix: /path1/
- uri:
prefix: /path2/
rewrite:
uri: /newpath/v1/
authority: test2
route:
- destination:
host: test2
- fault:
abort:
httpStatus: 444
percent: 100
route:
- destination:
host: test2
解决方案
推荐阅读
- mongodb - 在 2 个数据中心场景中设置 Active-Active mongo 的最佳方法?
- apache-flink - flink 流式维护窗口中特定事件的状态
- kubernetes - 警戒线和污点和容忍之间的区别(污点效应-NoExecute)
- javascript - 获取输入图像 Javascript 的尺寸
- javascript - 运行 cypress 测试时,令牌集被删除
- sql - 如何编写一个与第一列结果相关的查询?
- javascript - 如何获取浏览器的缩放级别
- botframework - 在 App Insights for QnA Maker 中寻找唯一的“对话 ID”
- python-3.x - 我如何在 keras 中将模型加载到多类分类
- python - 如何使用 python 使用密码 git clone SSH 密钥?