apiVersion: gateway.networking.k8s.io/v1beta1
kind: GatewayClass
metadata:
  name: istio
spec:
  controllerName: istio.io/gateway-controller
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
  name: gateway
  namespace: istio-system
spec:
  addresses:
  - value: istio-ingressgateway
    type: Hostname
  gatewayClassName: istio
  listeners:
  - name: http
    hostname: "*.domain.example"
    port: 80
    protocol: HTTP
    allowedRoutes:
      namespaces:
        from: All
  - name: tcp
    port: 34000
    protocol: TCP
    allowedRoutes:
      namespaces:
        from: All
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: http
  namespace: default
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  hostnames: ["first.domain.example"]
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /get
    backendRefs:
      - name: httpbin
        port: 80
        weight: 2
      - name: httpbin-other
        port: 8080
        weight: 3
      - name: httpbin-zero
        port: 8080
        weight: 0
  - matches:
    - path:
        type: PathPrefix
        value: /weighted-100
    backendRefs:
    - filters:
      - requestHeaderModifier:
          add:
          - name: foo
            value: bar
        type: RequestHeaderModifier
      - responseHeaderModifier:
          add:
          - name: response
            value: header
        type: ResponseHeaderModifier
      port: 8000
      name: foo-svc
      weight: 100
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
  name: tcp
  namespace: default
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  rules:
  - backendRefs:
    - name: httpbin
      port: 9090
      weight: 1
    - name: httpbin-alt
      port: 9090
      weight: 2
