Zero-to-jupyterhub-k8s: Ingress: Allow to run on subpath/subfolder, e.g. http://a.domain.com/jupyterhub

Created on 10 Oct 2019  路  4Comments  路  Source: jupyterhub/zero-to-jupyterhub-k8s

Hi there,

I have a question or rather maybe a feature request.

I would like to run jupyterhub in subdirectory, for example: devops.company.com/jupyterhub.
If the user then opens a browser on devops.company.com/jupyterhub, (s)he would be redirected to devops.company.com/jupyterhub/hub.

In the the chart, jupyterhub-0.9-4300ff5 | Mon, 30 Sep 2019 17:40:20 +0000 I see there is
pathSuffix

pathSuffix:
        type: string
        description: |
          Suffix added to Ingress's routing path pattern.
          Specify `*` if your ingress matches path by glob pattern.

If I set its value to /jupyterhub like here for example below, I get devops.company.com/hub/jupyterhub which would be also kind of expected.

ingress:
  enabled: true
  pathSuffix:
  annotations:
    kubernetes.io/ingress.class: traefik
  hosts:
    - ""

I have also already tried working with c.JupyterHub.base_url = '/jupyterhub/' in the hub-extraConfig but in that case, jupyterhub does not even start..

My ultimate goal would be to have in Traefik (my current proxy running in cluster) - for the jupyterhub frondend - this

PathPrefixStrip:/jupyterhub

Would it be possible to add path which would act as location from which jupyterhub should be run?
Thank you for any help.


Update 1

When c.JupyterHub.base_url = '/jupyterhub/' is added to extraconfig, then Hub seems to work to some degree as its API is listening on http://0.0.0.0:8081/jupyterhub/hub/

Adding default route for Hub: /jupyterhub/ => http://10.x.x.x:8081
Proxy: Fetching POST http://10.x.x.x:8001/api/routes/jupyterhub
302 GET /hub/api/users -> /jupyterhub/hub/hub/api/users ([email protected]) 7.01ms

Most helpful comment

Try setting hub.baseUrl instead:
https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/50e5599ce99b8b7ee8f21564d7a49accc5222541/jupyterhub/values.yaml#L10

If that doesn't work can you share your whole config?

All 4 comments

Try setting hub.baseUrl instead:
https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/50e5599ce99b8b7ee8f21564d7a49accc5222541/jupyterhub/values.yaml#L10

If that doesn't work can you share your whole config?

Thank you @manics ! I just got it work. Would a documentation PR for baseUrl in schema.yaml be accepted/approved?

For anyone looking for correct configuration:

hub:
baseUrl: /jupyterhub/
.......
extraConfig:
    myConfig.py: |
      c.JupyterHub.base_url = '/jupyterhub/'

extraConfig shouldn't be needed, if it is it's a bug! Is baseUrl correctly indented in your real config? It should be

hub:
  baseUrl: /jupyterhub

Note I'm not sure if the trailing / makes a difference

Indeed, you are right. / should not be there. Extra config is not needed either
Additionally I have added traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip which made it more complex and was wrong anyway.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

betatim picture betatim  路  4Comments

jonathanballs picture jonathanballs  路  3Comments

betatim picture betatim  路  4Comments

aurashn picture aurashn  路  4Comments

jgerardsimcock picture jgerardsimcock  路  4Comments