# istio_listenerset.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
  name: istio
spec:
  controllerName: istio.io/gateway-controller
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: parent-gateway
  namespace: istio-system
spec:
  allowedListeners:
    namespaces:
      from: All
  addresses:
  - value: istio-ingressgateway
    type: Hostname
  gatewayClassName: istio
  listeners:
    - name: foo
      hostname: foo.com
      protocol: HTTP
      port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: ListenerSet
metadata:
  name: single-entry-http
  namespace: istio-system
spec:
  parentRef:
    name: parent-gateway
    kind: Gateway
    group: gateway.networking.k8s.io
  listeners:
    - name: first
      hostname: first.foo.com
      protocol: HTTP
      port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: ListenerSet
metadata:
  name: single-entry-tls
  namespace: istio-system
spec:
  parentRef:
    name: parent-gateway
    kind: Gateway
    group: gateway.networking.k8s.io
  listeners:
    - name: second
      hostname: second.foo.com
      protocol: HTTPS
      port: 443
      tls:
        mode: Terminate
        certificateRefs:
          - kind: Secret
            group: ""
            name: my-cert-http
---
apiVersion: gateway.networking.k8s.io/v1
kind: ListenerSet
metadata:
  name: multi-entry
  namespace: istio-system
spec:
  parentRef:
    name: parent-gateway
    kind: Gateway
    group: gateway.networking.k8s.io
  listeners:
    - name: third
      hostname: third.foo.com
      protocol: HTTP
      port: 80
    - name: forth
      hostname: forth.foo.com
      protocol: HTTPS
      port: 443
      tls:
        mode: Terminate
        certificateRefs:
          - kind: Secret
            group: ""
            name: my-cert-http
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: bind-set
  namespace: istio-system
spec:
  parentRefs:
    - name: single-entry-http
      namespace: istio-system
      kind: ListenerSet
      group: gateway.networking.k8s.io
  rules:
    - matches:
        - path:
            value: /set
      backendRefs:
        - name: httpbin
          port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: bind-both
  namespace: istio-system
spec:
  parentRefs:
    - name: parent-gateway
    - name: single-entry-http
      namespace: istio-system
      kind: ListenerSet
      group: gateway.networking.k8s.io
  rules:
    - matches:
        - path:
            value: /both
      backendRefs:
        - name: httpbin
          port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: bind-parent
  namespace: istio-system
spec:
  parentRefs:
    - name: parent-gateway
  rules:
    - matches:
        - path:
            value: /parent
      backendRefs:
        - name: httpbin
          port: 80