apiVersion: gateway.networking.k8s.io/v1alpha2
kind: GatewayClass
metadata:
  name: istio
spec:
  controllerName: istio.io/gateway-controller
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: Gateway
metadata:
  name: gateway
  namespace: istio-system
spec:
  addresses:
  - value: istio-ingressgateway
    type: Hostname
  gatewayClassName: istio
  listeners:
  - name: default
    hostname: "*.domain.example"
    port: 80
    protocol: HTTP
    allowedRoutes:
      namespaces:
        from: All
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
  name: http
  namespace: default
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  hostnames: ["first.domain.example", "another.domain.example"]
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /get
      headers:
      - name: my-header
        value: some-value
        type: Exact
    filters:
    - type: RequestHeaderModifier
      requestHeaderModifier:
        add:
        - name: my-added-header
          value: added-value
        remove: [my-removed-header]
    backendRefs:
    - name: httpbin
      port: 80
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
  name: http2
  namespace: default
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  hostnames: ["second.domain.example"]
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /second
    backendRefs:
    - name: httpbin-second
      port: 80
  - matches:
    - path:
        type: PathPrefix
        value: /
    backendRefs:
    - name: httpbin-wildcard
      port: 80
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
  name: redirect
  namespace: default
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  rules:
  - filters:
    - type: RequestRedirect
      requestRedirect:
        port: 8080
        statusCode: 302
        scheme: https
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
  name: rewrite
  namespace: default
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /original
    filters:
    - type: URLRewrite
      urlRewrite:
        hostname: "new.example.com"
        path:
          type: ReplacePrefixMatch
          replacePrefixMatch: "/replacement"
    backendRefs:
    - name: httpbin
      port: 80
  - filters:
    - type: URLRewrite
      urlRewrite:
        path:
          type: ReplaceFullPath # Not currently supported
          replaceFullPath: "/replacement"
    backendRefs:
    - name: httpbin
      port: 80
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
  name: mirror
  namespace: default
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  rules:
  - filters:
    - type: RequestMirror
      requestMirror:
        backendRef:
          name: httpbin-mirror
          port: 80
    backendRefs:
    - name: httpbin
      port: 80
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
  name: http-not-selected
  namespace: default
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  hostnames: ["should.not.select"]
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /get
    backendRefs:
    - name: httpbin-bad
      port: 80