apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
  name: {{ .To.ServiceName }}-gateway
spec:
  selector:
    istio: {{.GatewayIstioLabel | default "ingressgateway"}}
  servers:
    - port:
        number: 80
        name: http
        protocol: HTTP
      hosts:
        - "*.{{ .To.ServiceName }}.com"
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: {{ .To.ServiceName }}
spec:
  hosts:
  - "*.{{ .To.ServiceName }}.com"
  gateways:
  - {{ .To.ServiceName }}-gateway
  http:
  - route:
    - destination:
        host: "{{ .To.ClusterLocalFQDN }}"
        port:
          number: {{ (.To.PortForName `http`).ServicePort }}
