使用自定义网关是否可以进行ISTIO内部流量路由?

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

即使使用自定义网关,ISTIO内部流量也可以路由到不同版本吗? (Azure App网关)。以下是我的用例。我有两种不同版本的部署(Kubernetes),其标签为app:myappversion: v1version: v2 [一个部署的v1标签,另一个部署的v2标签]。当前,流量在这两者之间平均分配,在kiali仪表板中也可以看到相同的流量。我只想将流量路由到v2。以下是我的虚拟服务和目的地规则。

虚拟服务:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: myvirtualservice
  namespace: mynamespace # Use same namespace with backend service
spec:
  hosts:
  - myservice.namespace.svc.cluster.local
  ingress:
  - appgw # define ingress name
  http:
  - match:
    - uri:
        prefix: "/"
    route:
    - destination:
        port:
          number: 80 # Backend service port
        host: myservice.namespace.svc.cluster.local # Backend service name
        subset: v2

目的地规则:

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: mydestrule
spec:
  host: myservice.namespace.svc.cluster.local
  subsets:
  - name: v2
    labels:
      version: v2

目前在kiali仪表板中,我的azure入口网关也显示为“未知”资源。

azure kubernetes istio azure-application-gateway
1个回答
1
投票

如果我正确看到它,则您在VirtualService的Destination中缺少子集选择器。如果您这样配置VirtualService,它应该会更好地工作:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: myvirtualservice
  namespace: mynamespace # Use same namespace with backend service
spec:
  hosts:
  - myservice.namespace.svc.cluster.local
  ingress:
  - appgw # define ingress name
  http:
  - match:
    - uri:
        prefix: "/"
    route:
    - destination:
        port:
          number: 80
        host: myservice.namespace.svc.cluster.local 
        subset: v2 # <- Route to the subset v2 and enable endpoint select by label

请参见https://istio.io/docs/reference/config/networking/virtual-service/#Destination

© www.soinside.com 2019 - 2024. All rights reserved.