# istio_listenerset-same-name-different-ns.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: default
    hostname: "*.example.com"
    protocol: HTTP
    port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: ListenerSet
metadata:
  name: same-name-http
  namespace: ns1
spec:
  parentRef:
    name: parent-gateway
    namespace: istio-system
    kind: Gateway
    group: gateway.networking.k8s.io
  listeners:
  - name: http
    hostname: first.example.com
    protocol: HTTP
    port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: ListenerSet
metadata:
  name: same-name-http
  namespace: ns2
spec:
  parentRef:
    name: parent-gateway
    namespace: istio-system
    kind: Gateway
    group: gateway.networking.k8s.io
  listeners:
  - name: http
    hostname: second.example.com
    protocol: HTTP
    port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: bind-ns1
  namespace: ns1
spec:
  parentRefs:
  - name: same-name-http
    namespace: ns1
    kind: ListenerSet
    group: gateway.networking.k8s.io
  rules:
  - matches:
    - path:
        value: /ns1
    backendRefs:
    - name: httpbin
      port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: bind-ns2
  namespace: ns2
spec:
  parentRefs:
  - name: same-name-http
    namespace: ns2
    kind: ListenerSet
    group: gateway.networking.k8s.io
  rules:
  - matches:
    - path:
        value: /ns2
    backendRefs:
    - name: httpbin
      port: 80