apiVersion: gateway.networking.k8s.io/v1alpha2 kind: GatewayClass metadata: name: higress spec: controllerName: higress.io/gateway-controller --- apiVersion: gateway.networking.k8s.io/v1alpha2 kind: Gateway metadata: name: gateway namespace: higress-system spec: addresses: - value: higress-gateway type: Hostname gatewayClassName: higress 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: higress-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] - type: ResponseHeaderModifier responseHeaderModifier: add: - name: my-added-resp-header value: added-resp-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: higress-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: higress-system rules: - filters: - type: RequestRedirect requestRedirect: port: 8080 statusCode: 302 scheme: https path: type: ReplaceFullPath replaceFullPath: /replace-full --- apiVersion: gateway.networking.k8s.io/v1alpha2 kind: HTTPRoute metadata: name: redirect-prefix-replace namespace: default spec: parentRefs: - name: gateway namespace: higress-system hostnames: ["redirect.domain.example"] rules: - matches: - path: type: PathPrefix value: /original filters: - type: RequestRedirect requestRedirect: port: 8080 statusCode: 302 scheme: https path: type: ReplacePrefixMatch replacePrefixMatch: /replacement --- apiVersion: gateway.networking.k8s.io/v1alpha2 kind: HTTPRoute metadata: name: rewrite namespace: default spec: parentRefs: - name: gateway namespace: higress-system rules: - matches: - path: type: PathPrefix value: /prefix-original name: prefix-path-rewrite filters: - type: URLRewrite urlRewrite: hostname: "new.example.com" path: type: ReplacePrefixMatch replacePrefixMatch: "/replacement" backendRefs: - name: httpbin port: 80 - matches: - path: type: PathPrefix value: /full-original name: full-path-rewrite filters: - type: URLRewrite urlRewrite: hostname: "new.example.com" path: type: ReplaceFullPath 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: higress-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: higress-system hostnames: ["should.not.select"] rules: - matches: - path: type: PathPrefix value: /get backendRefs: - name: httpbin-bad port: 80