首页 > 解决方案 > 为主机拆分虚拟服务是否可以使用通配符?

问题描述

我有两个虚拟服务,如下图所示,一个带有主机通配符,一个与特定主机匹配。这两个服务匹配不同的前缀。我的期望是 ISTIO 会将这些路由合并到 host mlp2012.mydomain.net。但这似乎不会发生。如果我将流量发送到http://mlp2012.mydomain.net/mlp2012/debug/echo;ISTIO 返回 404。但是,如果我删除了虚拟服务mlp2012-host。然后流量通过;表示第二个虚拟服务正在干扰 prefix 的路由/mlp2012/debug

这是否按预期工作?有人可以解释一下这种行为吗?

主机拆分的文档没有提到通配符。

# Create a wildcard route that correctly points at the service.
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: mlp2012-wildcard
  namespace: mlp-1
spec:
  gateways:
    - istio-system/ingressgateway
  hosts:
    - '*'
  http:
    - match:
        - uri:
            prefix: /mlp2012/debug/
      rewrite:
        uri: /
      route:
        - destination:
            port:
              number: 80
            host: echo-server


---

# Create a host specific route that points to a service that doesn't exist
# This should have a different prefix so it shouldn't match valid traffic.
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: mlp2012-host
  namespace: mlp-1
spec:
  gateways:
    - istio-system/ingressgateway
  hosts:
    - 'mlp2012.mydomain.net'
  http:
    - match:
        - uri:
            prefix: /mlp2012/doesnotexist/
      rewrite:
        uri: /
      route:
        - destination:
            port:
              number: 80
            host: doesnotexist

标签: istio

解决方案


推荐阅读