404 Error after setting Ingress pathSuffix

I am attempting to have the ingress-nginx controller route requests to certain namespace based on the suffix of the URL. For instance .com/namespace1 would point users to namespace1 in a GKE cluster.

I have ingress enabled in my Z2JH Helm chart.

ingress:
  enabled: true
  hosts:
    - "<NAME>.com"
  pathSuffix:
    "${class-section}"
  annotations: 
    kubernetes.io/ingress.class: "nginx"

The pathSuffix is currently just passing in a substitution variable in Terraform but seems to be working properly, this is used within a for_each type loop so that each ingress object has it’s own unique pathSuffix that relates to the namespace that the ingress is in.

Running kubectl describe ingress -n namespace1 gives the output of

Rules:
  Host                       Path  Backends
  ----                       ----  --------
  <NAME>.com
                             /namespace1   proxy-public:80 (11.1.1.29:8000)
Annotations:                 kubernetes.io/ingress.class: nginx
                                     meta.helm.sh/release-name: jupyterhub
                                     meta.helm.sh/release-namespace: namespace1

Then running kubectl describe ingress -n namespace2

Rules:
  Host                       Path  Backends
  ----                       ----  --------
  <NAME>.com
                             /namespace2   proxy-public:80 (11.1.1.30:8000)
Annotations:                 kubernetes.io/ingress.class: nginx
                             meta.helm.sh/release-name: jupyterhub
                             meta.helm.sh/release-namespace: namespace2

If I attempt to access .com or .com/namespace1 I get a 404 Not Found nginx.

If I do not use a pathSuffix input then I am able to access just .com

I am not sure what else I am missing.

Edit: I do have the proxy service set as a type of ClusterIP.

proxy:
  secretToken:
  service:
    type: ClusterIP

Does this need to be a NodePort?

Hi! Could you show us your full Z2JH config, with secrets redacted?

Here you go.

proxy:
  secretToken:
  service:
    type: ClusterIP

ingress:
  enabled: true
  hosts:
    - ""
  # pathSuffix:
  #   "${class-section}"
  annotations: 
    kubernetes.io/ingress.class: "nginx"

hub:
  config:
    Authenticator:
      admin_users:
      allowed_users:
    DummyAuthenticator:
      password: 
    JupyterHub:
      authenticator_class:
singleuser:
  defaultUrl: "/lab"

scheduling:
  userScheduler:
    enabled: false
  podPriority:
    enabled: false
  userPlaceholder:
    enabled: true
    replicas: 2
  userPods:
    nodeAffinity:
      matchNodePurpose: require

cull:
  enabled: true
  timeout: 3600
  every: 3600

Can you try setting hub.baseUrl to match your suffix?

Sure, so just so I understood I would do something like this.

ingress:
   pathSuffix:
      /namespace1
hub:
   baseUrl: /namespace1
1 Like

Thanks @maniacs, I was able to get this to work. I only set hub.baseUrl to /namespace1 and can access website.com/namespace1 and see a kubectl events log in that namespace.

Is it necessary to set pathSuffix? I had noticed in another post from you that it wasn’t necessary to set. When exactly would you use this pathSuffix field? Trouble configuring Ingress for Helm Chart - #2 by manics

Now I’ve come across another issue with actually getting an environment stood up and get an error about Spawn failed: Server at http://<IP>:8888/namespace1/user/admin2/ didn't respond in 30 seconds. I am attempting to login as admin2 and using the dummy authenticator.

You shouldn’t need to set pathSuffix, hub.baseUrl configures JupyterHub and also the ingress.

The documentation on this is quite brief and I’ve never had to use it:

Suffix added to Ingress’s routing path pattern.
Specify * if your ingress matches path by glob pattern.

1 Like