【问题标题】:Istio HTTPMatchRequest seems to match request using OR logic instead of the documented AND logicIstio HTTPMatchRequest 似乎使用 OR 逻辑而不是文档化的 AND 逻辑来匹配请求
【发布时间】:2019-09-17 00:02:17
【问题描述】:

根据https://istio.io/docs/reference/config/networking/v1alpha3/virtual-service/#HTTPMatchRequest

HttpMatchRequest 指定要满足的一组标准,以便将规则应用于 HTTP 请求。例如,以下规则将规则限制为仅匹配 URL 路径以 /ratings/v2/ 开头且请求包含值为 jason 的自定义最终用户标头的请求。

我认为这意味着匹配应该是 AND 类型。

下面是一个 istio 虚拟服务定义。根据上面的定义,我假设这个虚拟服务只允许 POST /status/...

形式的请求

但是,似乎逻辑实际上是 OR,即 POST 请求或(例如,GET /status/xxx)请求通过 .有人可以解释或更正我的配置吗?

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: "httpbin-virtual-service"
spec:
  hosts:
  - "*"
  gateways:
  - my-istio-gateway
  http:
  - match:
    - method:
        exact: POST
    - uri:
        prefix: /status
    route:
    - destination:
        host: "httpbin"
        port:
          number: 80 # application port

输出

$ siege -c1 -d1 --content-type "application/json" '127.0.0.1:31380/delay/2 POST {"ids": ["1","2","3"]}' ==> not a request to /status/.. , why does this match
HTTP/1.1 200     2.00 secs:    1072 bytes ==> POST http://127.0.0.1:31380/delay/2
HTTP/1.1 200     2.01 secs:    1072 bytes ==> POST http://127.0.0.1:31380/delay/2
..

$ siege -c1 -d1 127.0.0.1:31380/status/200  ====================> not a POST request , why does this match
HTTP/1.1 200     0.00 secs:       0 bytes ==> GET  /status/200
HTTP/1.1 200     0.00 secs:       0 bytes ==> GET  /status/200
..

【问题讨论】:

    标签: istio


    【解决方案1】:

    已解决,我在uri前有一个“-”

    正确的配置应该是

    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: "httpbin-virtual-service"
    spec:
      hosts:
      - "*"
      gateways:
      - my-istio-gateway
      http:
      - match:
        - method:
            exact: POST
          uri:
            prefix: /status
        route:
        - destination:
            host: "httpbin"
            port:
              number: 80 # application port
    

    【讨论】:

      猜你喜欢
      • 2015-09-29
      • 2011-12-26
      • 2023-03-12
      • 2017-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多