是否可以在单个网关中设置多个共享同一主机的VirtualService?

问题描述 投票:0回答:1

假设我有VirtualService Foo,它有规则管理team.company.com/foo http路径,并将其绑定到网关TeamGateway(有主机team.company.com)。然后引入另一个VirtualService Bar来管理某些后端的team.company.com/bar规则路径,绑定到同一个网关TeamGateway。可能吗?

kubernetes istio
1个回答
0
投票

很可能你可以通过匹配uri前缀甚至使用1 VirtualService来做到这一点。

Gateway应该看起来像:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: your-new-gateway
spec:
  selector:
    app: your-new-gateway-controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - team.company.com

定义网关后,您创建VirtualService将其匹配到不同的前缀:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: vs-rule
spec:
  hosts:
  - team.company.com
  gateways:
  - your-new-gateway
  http:
  - match:
      uri:
        prefix: /foo/
    route:
    - destination:
        host: your_1.svc.cluster.local #Kubernetes underlying service name
  - match:
      uri:
        prefix: /bar/
    route:
    - destination:
        host: your_2.svc.cluster.local #Kubernetes underlying service name
© www.soinside.com 2019 - 2024. All rights reserved.