Istio VirtualService HTTPRewrite 被完全忽略

Istio VirtualService HTTPRewrite being ignored completely

我在 api-service 部署 pods 和默认 istio-ingressgateway 部署中检查了 istio-proxy sidecar 容器的日志。路径保持不变,未写入从入口网关到我的服务。我希望请求看起来像:

Client: 'GET mysite.com/api/some-resource/123/'
  ||
  ||
  VV
Ingressgateway: 'GET mysite.com/api/some-resource/123/'
  ||
  ||
  VV
VirtualService: rewrite.uri: /
  ||
  ||
  VV
api-service: 'GET mysite.com/some-resource/123/'

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-route-rules
spec:
  hosts:
    - mysite.com
  gateways:
    - istio-system/mysite-gateway
  http:
    - match:
      - uri:
          prefix: /api
      rewrite:
        uri: /
      route:
        - destination:
            host: api-service.default.svc.cluster.local
            port:
              number: 7000
    - route:
        - destination:
            host: web-experience.default.svc.cluster.local
            port:
              number: 9000

我发现重定向确实有效,但 envoy sidecar 并没有像我假设的那样在其日志中反映出来。

我从 the docs 推断出 envoy sidecar 会记录重写的路径(查看 rewrite 字段的 Description ):

Rewrite will be performed before forwarding.

我在我的 api-service 部署中检查了我的 Web 服务器 运行 的访问日志,发现格式错误的请求:GET //some-resource/123/(来自 /api/some-resource/123/)。

原来额外的 /(来自 rewrite.url: /)导致了 404 错误。 A Github comment from an istio issue 提出了一个修复:空格。

如用户警告,不确定此行为是否有意。