I’m using LDAP authentication to authenticate users for our Jupyterhub running in Kubernetes (using z2jh helm chart).
Currently, I’m trying to get the singleuser servers to run as the user, with the proper UID and GID provided from LDAP. I can set that up just fine using auth_state_attributes and can pull that in through extraConfig to set NB_USER, NB_UID, NB_GID but am still running into issues getting the singleuser server to run with those respectively.
When trying to run with the singleuser UID set to 0, I get [C 2021-04-29 19:24:22.134 SingleUserNotebookApp notebookapp:2204] Running as root is not recommended. Use --allow-root to bypass.
I suppose to note, if I don’t set the UID to 0 for the singleuser server, it starts and the NB_UID and NB_GID will be set in the environment, but the container won’t be running under that UID. Setting the singleuser UID to 0 and the pod doesn’t start.
Thanks much! That does allow the notebook to run as the specified user.
Now though, it seems that the singleuser.defaultUrl in the Z2JH config is no longer used.
I’ve tried a few different ways to set it, like c.Spawner.default_url = '/lab and setting certain environment variables, but doesn’t seem to work. Will probably have to see how that gets set into the singleuser command. Perhaps the additional flags aren’t being set?
Yes, unfortunately it’s a bit complicated… If you want to use the default command from the Docker image you can unset singleuser.cmd, but if you want to use the default command with other Spawner parameters you have to explicitly add the default, which as you figured out is start-notebook.sh.
Old thread, but hoping @manics you can shed some light in my z2jh deployment if you get a chance.
I have managed with your examples to get NB_UID etc resolving to the right user attributes inside the pod, when I set “cmd:” as blank with uid=0, I get a permissions issue when the default script tries to run as it seems to be trying to write stuff to the NFS folder (/home//.local) before switching to running as the user (My NFS user folders are tied down with 700 permissions.).
I copied your start.sh above to my container, and called it from the cmd: option, and the logs show it ran ok (no errors at least), the container completes successfully (according to k8s) but the pod doesn’t stay running.
So what’s running when I leave cmd: as blank? And how do I get the pod to stay running if I call your start.sh using cmd: option?