Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

c.KubeSpawner.default_url = '/lab' is correct? #149

Closed
lfzyx opened this issue Mar 21, 2018 · 11 comments
Closed

c.KubeSpawner.default_url = '/lab' is correct? #149

lfzyx opened this issue Mar 21, 2018 · 11 comments

Comments

@lfzyx
Copy link

lfzyx commented Mar 21, 2018

I set c.KubeSpawner.default_url = '/lab', but when I login from hub , the default url still is /tree.

Other configuration:

c.KubeSpawner.singleuser_image_spec = 'jupyterhub/singleuser:latest'

c.KubeSpawner.singleuser_service_account = 'default'

c.JupyterHub.allow_named_servers = True
@lfzyx lfzyx changed the title c.KubeSpawner.default_url = '/lab' is valid? c.KubeSpawner.default_url = '/lab' is correct? Mar 21, 2018
@lfzyx
Copy link
Author

lfzyx commented Mar 22, 2018

I see the difference between KubeSpawner and dockerspawner

KubeSpawner

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   4372   740 ?        Ss   02:25   0:00 tini -- start-notebook.sh
root         7  0.0  0.0  47012  3612 ?        S    02:25   0:00 sudo -E -H -u jovyan PATH=/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PYTHONPATH= jupyterhub-singleuser --ip=0.0.0.0
jovyan      17  0.0  0.1 283972 61840 ?        Sl   02:25   0:01 /opt/conda/bin/python /opt/conda/bin/jupyterhub-singleuser --ip=0.0.0.0
root        65  0.0  0.0  19928  3860 ?        Ss   02:35   0:00 bash
root        96  0.0  0.0  36088  3212 ?        R+   03:27   0:00 ps aux

dockerspawner

USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
jovyan        1  0.0  0.0   4368   656 ?        Ss   Mar21   0:01 tini -- start-notebook.sh --ip="0.0.0.0" --port=8888 --notebook-dir="/home/jovyan/work" --NotebookApp.default_url="/lab"
jovyan        7  0.0  0.7 656340 64496 ?        Sl   Mar21   0:13 /opt/conda/bin/python /opt/conda/bin/jupyterhub-singleuser --ip="0.0.0.0" --port=8888 --notebook-dir="/home/jovyan/work" --NotebookApp.default_url="/lab"
jovyan       29  0.0  0.5 632156 43680 ?        Ssl  Mar21   0:03 /opt/conda/bin/python -m ipykernel_launcher -f /home/jovyan/.local/share/jupyter/runtime/kernel-eeaebb52-c6ed-47e4-a295-8784ed59cb4e.json
jovyan       32  0.0  0.5 632800 44232 ?        Ssl  Mar21   0:03 /opt/conda/bin/python -m ipykernel_launcher -f /home/jovyan/.local/share/jupyter/runtime/kernel-b5a5610d-ce6b-441a-b208-5f67fdd6593b.json
jovyan       82  0.0  0.0  19928  3680 pts/0    Ss   02:33   0:00 bash
jovyan      103  0.0  0.0  36084  3160 pts/0    R+   03:27   0:00 ps aux

@gweis
Copy link
Contributor

gweis commented Jul 4, 2018

Workaround:

Looking at the code here https://github.com/jupyterhub/kubespawner/blob/master/kubespawner/spawner.py#L1159 , you can see that self.get_args() is only called when self.cmd is set. For a standard jupyter notebook image (from jupyter/docker-stack) it should be enough to set it to KubeSpawner.cmd = ['start-notebook.sh']. With this set, you'll get the same arguments set as with DockerSpawner.

I guess this check is there to avoid overriding the default CMD set in the docker image, but some documentation or maybe even setting it to a default value used with the Jupiter/docker-stack images would be useful. Even if it is to force a user to change it when needed.

@dkipping
Copy link

dkipping commented Jan 10, 2019

I am currently also facing the issue that I can not set jupyterlab as the default, even though it seems to be more complicated in my case.

I am using a custom spawner build upon the kubespawner and providing

c.CustomFormSpawner.default_url = '/lab'
c.CustomFormSpawner.cmd = ['jupyter-labhub']

Does not lead to jupyterlab being loaded initially.

I am instead even getting an error jupyterlab-hub: No configuration found. on the browser console when manually switching to the jupyterlab by altering the url.

This seems to have to do with me providing an own entrypoint script in the image used for the single user, because I have to execute some steps that can not be executed during the construction in the Dockerfile:

End of Dockerfile:

ENTRYPOINT ["bash", "/usr/src/app/my-entrypoint.sh"]
CMD ""

end of my-entrypoint.sh:

exec tini -g -- "start-notebook.sh"

It seems that this way, the parameters do not have any effect.

To mention:

I am using z2jh, adding the lab parameters directly via the z2jh interface instead of in the extraconfig also didn't help.

I already tried to replace the command at the end of my entrypoint-script with:

exec tini -g -- "/usr/local/bin/start.sh jupyter lab"

(Also tried that without the path to the file)

As this should according to the docker-stacks be a way to execute jupyter lab after startup of the notebook environment, but this just causes the container to terminate directly, so it does not even start up successfully.

My question:
Have you (or has anybody) already had experience or have an idea how to set jupyterlab as the default and make the single user servers launch with jupyterlab? (keeping our custom image and its entrypoint script) So did you achieve setting it as default after @gweis ' tip?

I guess I would somehow have to hand in the parameters to the exec command in the entrypoint script? Or is there really an issue with the lab parameters for kubespawner?

I also already tried

exec tini -g -- 'start-notebook.sh "@"'

as well as leaving away the outer quotes. But that also had the startup failing completely

@gweis
Copy link
Contributor

gweis commented Jan 10, 2019

I am using custom docker images as well, but I went with the startup scripts from https://github.com/jupyter/docker-stacks/tree/master/base-notebook
and put my custom start-up scripts into /usr/local/bin/start-notebook.d (loaded here https://github.com/jupyter/docker-stacks/blob/master/base-notebook/start.sh#L39)

Just be careful with scripts in that folder as scripts ending with .sh will be sourced and all other executable file will run in a sub shell.

I guess most of the documentation and examples are tied to the entry point scripts provided by the docker-stacks images.

@consideRatio
Copy link
Member

Hmmm I dont understand why, but perhaps you need to set c.Spawner.default_url rather than c.KubeSpawner.defualt_url? I recall some issue with this myself that i never grasped.

PS: this may be useful to have watched to better grasp whats going om: https://m.youtube.com/watch?v=_gYEVTaNuKU

See https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/master/images/hub/jupyterhub_config.py

@dkipping
Copy link

dkipping commented Jan 11, 2019

Thank you both for your feedback!

@gweis That is amazing. I didn't read the scripts careful enough to know that this is possible. Hopefully that already simplifies the image and script and makes the jupyterlab thing work

@consideRatio Thanks for the resources! Yeah I already tried setting the attributes on my custom spawner and directly on the spawner class. I think the entrypoint script was blocking it. Will have a look, what is the easiest/most intuitive way to make it work now.

@dkipping
Copy link

dkipping commented Jan 14, 2019

UPDATE:

So the method as suggested by gweis works, then the Spawner.default_url and the Spawner.cmd are respected.

However this is not working out of the box when you try to grant sudo to the users.

Referring to jupyterhub/zero-to-jupyterhub-k8s#562, you would have to set

singleuser:
  uid: 0

which results in the following error:

[C 2019-01-11 13:58:06.816 SingleUserNotebookApp notebookapp:1707]Running as root is not recommended. Use --allow-root to bypass.

Following the tip to set:

singleuser:
  cmd: null

as provided in the thread (jupyterhub/zero-to-jupyterhub-k8s#562 (comment)) is not an option, as setting jupyter-labhub is required to be set in the spawner settings.

Guess one would have to fall back to provide the sudo rights in our custom image as proposed in the same thread:
jupyterhub/zero-to-jupyterhub-k8s#562 (comment)

@consideRatio
Copy link
Member

This issue is quite old and many things have changed since it was written, but to summarize.

  • singleuser.defaultUrl is the z2jh helm chart config to set c.Spawner.default_url
  • jupyter-labhub should no longer be used

@jacogasp
Copy link

jacogasp commented Mar 9, 2021

I still face this issue.
For me c.KubeSpawner.default_url has no effect whatever url I set (/notebooks, /lab...)

@EtgarSH
Copy link

EtgarSH commented Oct 12, 2021

I still face this issue. Does someone have a workaround solution?

@yuvipanda
Copy link
Collaborator

If you were using JupyterHub 2.0, it might be fixed by jupyterhub/jupyterhub#3918 in 2.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants