VirtualService资源与Gateway资源相互配合支持Envoy的配置。下面是一个支持HTTP服务的网关虚拟服务的基本配置:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: counter
spec:
gateways:
- default-gateway.istio-system.svc.cluster.local
hosts:
- counter.lab.example.com
http:
- match:
- uri:
prefix: /
route:
- destination:
host: counter
port:
number: 80
现在,当我们添加一个Gateway和一个VirtualService时,路由已在Envoy配置中创建。要查看此内容,你可以使用如下命令:
kubectl port-forward istio-ingressgateway-xxxx-yyyy-n istio-system 15000
通过访问地址http://localhost:15000/conf ig_dump来查看配置。