Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

HTTPRoute with RequestRedirect results in invalid spec #390

Open
lehmanju opened this issue Mar 5, 2025 · 4 comments · May be fixed by #391
Open

HTTPRoute with RequestRedirect results in invalid spec #390

lehmanju opened this issue Mar 5, 2025 · 4 comments · May be fixed by #391
Assignees
Labels
bug Something isn't working

Comments

@lehmanju
Copy link

lehmanju commented Mar 5, 2025

Details

What steps did you take and what happened:

Used following snippet:

route:
  main:
    parentRefs:
      - name: paperless-web
        namespace: paperless
        sectionName: https
    hostnames:
      - paperless.lan
    rules:
      - backendRefs:
          - kind: Service
            port: 80
            name: app
  redirect:
    parentRefs:
      - name: paperless-web
        namespace: paperless
        sectionName: http
    hostnames:
      - paperless.lan
    rules:
      - filters:
        - type: RequestRedirect
          requestRedirect:
            scheme: https
            statusCode: 301

This results in

# Source: app-template/templates/common.yaml
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
  name: paperless-redirect
  labels:
    app.kubernetes.io/instance: paperless
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: paperless
    helm.sh/chart: app-template-3.7.2
  namespace: default
spec:
  parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: paperless-web
      namespace: paperless
      sectionName: "http"
  hostnames:
    - "paperless.lan"
  rules:
  - backendRefs:
    filters:
      - requestRedirect:
          scheme: https
          statusCode: 301
        type: RequestRedirect

where backendRefs is empty and thus rejected because its value is 'null'.

What did you expect to happen:

backendRefs should be missing if not set

@lehmanju lehmanju added the bug Something isn't working label Mar 5, 2025
@larivierec
Copy link
Contributor

larivierec commented Mar 10, 2025

This was done awhile back: 807dc71#diff-0b71571fdca8114ef5b6af19537d8ac82dcfbbd9ebcad4372ca1411e58c50180R77-R79

backendRefs should not be set as you can't use both here
test ref: test

i'd have to investigate

@lehmanju
Copy link
Author

Yeah, it's impossible to use backendRefs and requestReditect simultaneously in the helm template but unfortunately the generated resource is not accepted by the cluster.

@lehmanju
Copy link
Author

@larivierec
Copy link
Contributor

Yes, you are right. It passes validation and then renders the route class.

We have to figure out a way to remove that when rules contain a request redirect filter.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants