Skip to content

Ingress with a subpath has a hard-coded trailing slash #3623

Open
@johnflavin

Description

@johnflavin

Bug description

I am trying to deploy JH to a subpath, e.g. <mydomain>/jupyter. I set hub.baseUrl=/jupyter and enable ingress, but the Ingress object is not correctly configured, it has a trailing slash: path: /jupyter/.

How to reproduce

Use helm to install jupyter with ingress enabled and a subpath on hub.baseUrl.

helm upgrade --install \
	jupyter jupyterhub/jupyterhub \
	--namespace jupyter \
	--version=4.1.0 \
	--set proxy.service.type=ClusterIP \
	--set hub.baseUrl=/jupyter \
	--set ingress.enabled=true,ingress.hosts="{<mydomain>}"

Expected behaviour

Jupyter is served from <mydomain>/jupyter

Actual behaviour

  • <mydomain>/jupyter is a 404 served by traefik (my IngressController), indicating that traefik does not route that path to Jupyter.
  • If I instead navigate to <mydomain>/jupyter/ with a trailing slash, it does route correctly and JH loads as expected.

The Ingress that gets created by helm looks like this:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    meta.helm.sh/release-name: jupyter
    meta.helm.sh/release-namespace: jupyter
  creationTimestamp: "2025-02-13T21:02:34Z"
  generation: 11
  labels:
    app: jupyterhub
    app.kubernetes.io/component: ingress
    app.kubernetes.io/instance: jupyter
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: jupyterhub
    chart: jupyterhub-4.1.0
    component: ingress
    helm.sh/chart: jupyterhub-4.1.0
    heritage: Helm
    release: jupyter
  name: jupyterhub
  namespace: jupyter
  resourceVersion: "2407046"
  uid: a3b6128c-bef4-4997-be30-b1c70320e876
spec:
  ingressClassName: traefik
  rules:
  - host: <mydomain>
    http:
      paths:
      - backend:
          service:
            name: proxy-public
            port:
              name: http
        path: /jupyter/
        pathType: Prefix

Note that the path is path: /jupyter/ with a trailing slash. That is because of line 20 in the ingress template:

- path: {{ $.Values.hub.baseUrl | trimSuffix "/" }}/{{ $.Values.ingress.pathSuffix }}

Since I have set hub.baseUrl but haven't set anything for ingress.pathSuffix, this has the effect of appending a slash to the value I set in hub.baseUrl. This prevents routing to the slash-free subpath.

If I patch the ingress with this file:

spec:
  ingressClassName: traefik
  rules:
  - host: <mydomain>
    http:
      paths:
      - backend:
          service:
            name: proxy-public
            port:
              name: http
        path: /jupyter
        pathType: Prefix

using the command

kubectl -n jupyter patch ingress jupyterhub --type strategic --patch-file jupyterhub-ingress.yaml

Then the Ingress path is set to /jupyter, and navigating to <mydomain>/jupyter works as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions