VirtualService is defined in a cluster, but test results show that the defined rule does not take effect. This problem is usually caused by inappropriate configurations. This section lists common possible reasons.gateways field is not specified for VirtualService, it actually implies that Istio will add a reserved gateway called "mesh" by default, which indicates all sidecars in the cluster. In other words, this VirtualService rule will take effect for intra-cluster access.gateways field is specified, Istio will not add "mesh" by default. For example:apiVersion: networking.istio.io/v1beta1kind: VirtualServicemetadata:name: productpagespec:gateways:- istio-test/test-gatewayhosts:- bookinfo.example.comhttp:- route:- destination:host: productpageport:number: 9080
VirtualService rule will take effect only for the gateway istio-test/test-gateway. For intra-cluster access, the traffic will not pass through this gateway, so the rule will not take effect.gateways.gateways:- istio-test/test-gateway- mesh
VirtualService will take effect for both the gateway istio-test/test-gateway and the intra-cluster access.
hosts field.hosts:- bookinfo.example.com- productpage
hosts fields in Gateway and VirtualService both contain the actual host used for access or a host name that can be matched by using a wildcard, usually an external domain name.hosts field in Gateway or VirtualService is not defined correctly, 404 Not Found will be returned. Correct configuration examples are as follows:apiVersion: networking.istio.io/v1alpha3kind: Gatewaymetadata:name: test-gatewaynamespace: istio-testspec:selector:app: istio-ingressgatewayistio: ingressgatewayservers:- port:number: 80name: HTTP-80-wwwprotocol: HTTPhosts:- bookinfo.example.com # Define an external access domain name.---apiVersion: networking.istio.io/v1beta1kind: VirtualServicemetadata:name: productpagespec:gateways:- istio-test/test-gatewayhosts:- bookinfo.example.com # Define the external access domain name.http:- route:- destination:host: productpageport:number: 9080
Feedback