Jupyterhub User Subdomaining on K3S

I installed Jupyterhub in my K3S instance using Helm. My goal is to enable user subdomains as https://jupyterhub.readthedocs.io/en/3.0.0/reference/websecurity.html#enable-subdomains suggests.

I used the below configuration, to link the Jupyterhub instance through ingress and ensure tls encryption with a basic certificate for the base URL and a wildcard certificate for the user subdomains.
WIthout user subdomains enabled this works fine.
After logging in the user is directed to “https://base-url.example.com/user/testuser/lab?

ingress:
  enabled: true
  hosts:
    - "base-url.example.com"
    - "*.base-url.example.com"
  tls:
    - hosts:
        - "base-url.example.com"
      secretName: simple-tls-secret
    - hosts:
        - "*.base-url.example.com"
      secretName: wildcard-tls-secret
proxy:
  service:
    type: ClusterIP

# Configuration for User Subdomaining
# hub:
#  extraConfig:
#    myConfig.py:
#      c.JupyterHub.subdomain_host="https://base-url.example.com"

When I enable the commented out configuration however my Jupyterhub instance starts to behave badly.
After login the user is directed to “https://testuser.base-url.example.com/hub/user/testuser/lab” and gets displayed a “500: Internal server error redirect loop detected.”

The hub pod logs show several times in succession:

[timestamp] 302 GET /hub/user/testuser/labs? -> https://testuser.base-url.example.com/user/testuser/lab?
[timestamp] 302 GET /user/testuser/lab? -> /hub/user/testuser/labs?

until finally it shows:

[timestamp] 500 GET /hub/user/testuser/lab? : Redirect loop detected.

and closes the connection.
I am guessing that the redirect has an error and should usually strip:

https://testuser.base-url.example.com/user/testuser/lab?

down to:

https://testuser.base-url.example.com/lab?

or something like this. Or maybe it is something else entirely. Does anyone have any ideas?

Z2JH isn’t tested or supported with subdomains.

However, a few things you could try are:

  • Turn on debug logging
  • Are you able to get JupyterHub working with subdomains without the Helm Chart? This means you have full control over jupyterhub_config.py and can iteratively modify it, and will help identify whether KubeSpawner handles subdomains
  • If KubeSpawner doesn’t work, then are you able to get JupyterHub working with subdomains but without Kubernetes, i.e. using a different spawner?