apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
  name: {{ .To.ServiceName }}-gateway
spec:
  gatewayClassName: istio
  listeners:
  - name: http
    port: 80
    protocol: HTTP
    hostname: "*.{{ .To.ServiceName }}.com"
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: {{ .To.ServiceName }}
spec:
  parentRefs:
  - name: {{ .To.ServiceName }}-gateway
  hostnames:
  - "*.{{ .To.ServiceName }}.com"
  rules:
  - backendRefs:
    - name: "{{ .To.ServiceName }}"
      port: {{ (.To.PortForName `http`).ServicePort }}
