skip to Main Content

Looking at ingress options we’ve found that the Gateway ressource was on paper the better fit for us compared to traditional nginx Ingresses or managed Ingresses (since those need to provision one LB for every one ingress).

After wrapping my head around the grammar of Gateways and HTTPRoutes, I’ve managed to achieve most of what I wanted to but I’m getting stuck on HTTP->HTTPS redirections. On a regular Ingress it’s just a matter of setting redirectToHttps in a FrontendConfig, and as per the k8s API documentation the same should be achievable through a RequestRedirect filter in the HTTPRoute.

As it happens, there doesn’t seem to be any support or implementation of this feature on GKE. But I still need to redirect HTTP to HTTPS requests somehow. While I’m sure there are ways of doing it, I’m looking for one that’s not too hacky.

This basic HTTPRoute example from the official documentation produces an error on GKE.

apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: http-filter-redirect
spec:
  hostnames:
    - redirect.example
  rules:
    - filters:
        - type: RequestRedirect
          requestRedirect:
            scheme: https
            statusCode: 301

Error GWCER104: HTTPRoute "default/http-filter-redirect" is misconfigured, err: unsupported filter type: RequestRedirect.

As per the Google documentation of GatewayClass, the requestRedirect filter is not available.

3

Answers


  1. Currently, it appears that the HTTPRoute API for the Gateway resource in GKE does not support the requestRedirect filter. Kindly open an issue tracker and submit this as a potential feature request for now. Please use the provided link to submit your feature request.

    Login or Signup to reply.
  2. HTTP to HTTPS redirect is still not supported by our Gateway Controller. For a full list of supported features take a look at this page https://cloud.google.com/kubernetes-engine/docs/how-to/gatewayclass-capabilities

    And keep an eye on it. It will be updated when the redirect is supported.

    Login or Signup to reply.
  3. It is supported in GA now.

    apiVersion: v1
    kind: HTTPRoute
    apiVersion: gateway.networking.k8s.io/v1beta1
    metadata:
      name: redirect
      namespace: gateway-infra
    spec:
      parentRefs:
      - namespace: gateway-infra
        name: external-http
        sectionName: http
      rules:
      - filters:
        - type: RequestRedirect
          requestRedirect:
            scheme: https
    

    https://cloud.google.com/kubernetes-engine/docs/how-to/deploying-gateways#configure_http-to-https_redirects

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search