使用GreaterThan / LessThan评估Istio规则匹配

时间:2019-11-25 17:44:06

标签: istio telemetry

看看Istio Rule.match,.. https://istio.io/docs/reference/config/policy-and-telemetry/istio.policy.v1beta1/#Rule的功能,如何在GreaterThan / LessThan上进行匹配,而不是仅仅存在/相等检查

例如。我将如何实现这样的目标(标头值> 24)

spec:
  match: match((request.headers["some-header"] | 24) >"24") 

1 个答案:

答案 0 :(得分:0)

问题中提到的规则由于属性类型不匹配而无法正常工作。


但是,可以使用通用表达语言CEL)。

您可以使用policy.istio.io/lang批注(将其设置为CEL)在istio中启用CEL。

然后通过使用Type Values中的List of Standard Definitions,我们可以使用create函数将值解析为不同的类型。

例如:int()得到一个string并产生一个int,我们可以 然后与_>_ (int, int) -> bool进行比较。