apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: mesh-route-outbound-traffic-to-external-svc-via-egress-gw
spec:
  hosts:
  - external.{{ .externalNamespace }}.svc.cluster.local
  gateways:
  - mesh
  tcp:
  - match:
    - port: {{ .externalSvcTcpPort }}
    route:
    - destination:
        host: istio-egressgateway.istio-system.svc.cluster.local
        port:
          number: 80
  tls:
  - match:
    - port: {{ .externalSvcTlsPort }}
      sniHosts:
      - external.{{ .externalNamespace }}.svc.cluster.local
    route:
    - destination:
        host: istio-egressgateway.istio-system.svc.cluster.local
        port:
          number: 443
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: egress-gw-route-outbound-traffic-to-external-svc-via-external-forward-proxy
spec:
  hosts:
  - external.{{ .externalNamespace }}.svc.cluster.local
  gateways:
  - istio-egressgateway
  tcp:
  - match:
    - port: 80
    route:
    - destination:
        host: external-forward-proxy.{{ .externalNamespace }}.svc.cluster.local
        subset: external-svc-tcp
        port:
          number: {{ .forwardProxyPort }}
  - match:
    - port: 443
    route:
    - destination:
        host: external-forward-proxy.{{ .externalNamespace }}.svc.cluster.local
        subset: external-svc-tls
        port:
          number: {{ .forwardProxyPort }}
