5.2.3 定义虚拟服务

定义虚拟服务(VirtualService),为通过入口网关进入的流量进行路由配置,具体代码可参见目录mtls-go-example/https下的文件httpbin-vs.yaml:


kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: httpbin
spec:
  hosts:
  - "httpbin.example.com"
  gateways:
  - mygateway
  http:
  - match:
    - uri:
        prefix: /status
    - uri:
        prefix: /delay
    route:
    - destination:
        port:
          number: 8000
        host: httpbin
EOF