---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: {{k8s_deploy.namespace}}-gwy
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway # use istio default ingress gateway
  servers:
  {%- for prxy in k8s_deploy.prxyGatewayServers %}
  - port:
      number: {{ prxy.port.number }}
      name: {{ prxy.port.name }}
      protocol: {{ prxy.port.proto }}
    {%- if prxy.tls %}
    tls:
      {%- if prxy.tls.httpsRedirect %}
      httpsRedirect: true
      {%- endif %}
      {%- if prxy.tls.mode and prxy.tls.mode != "" %}
      mode: {{prxy.tls.mode}}
      {%- endif %}
      {%- if prxy.tls.credentialName %}
      credentialName: {{prxy.tls.credentialName}}
      {%- endif %}
    {%- endif %}
    {%- if prxy.hosts %}
    hosts:
    {%- for host in prxy.hosts %}
    - "{{host}}"
    {%- endfor %}
    {%- endif %}
  {%- endfor %}
