apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
  name: {{ .To.ServiceName }}-gateway
spec:
  gatewayClassName: istio
  listeners:
  - name: http
    # Exposing port 80 isn't the recommended security practice 
    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:
  - matches:
    - path: 
        type: PathPrefix
        value: /allow
      method: GET
    backendRefs:
    - name: "{{ .To.ServiceName }}"
      port: {{ (.To.PortForName `http`).ServicePort }}
