Hello members.
1. My Goal.
When a user logs in to the Z2JH, I want to change the user’s UID/GID and Home.
All of the user’s data is stored in the LDAP server.
I found this page. And I’m trying to this setting.
- Store notebook data in the specific directory (User’s home) in the NFS directory.
- Use the user’s UID/GID
2. Problem.
When the user bob
logs in to the Z2JH, the server doesn’t respond in 30 seconds. and failed to launch the cluster.
2023-10-06T11:44:26.947238Z [Normal] Successfully assigned ns-z2jh/jupyter-bob to k8node2
2023-10-06T11:44:27Z [Normal] Container image "jupyterhub/k8s-network-tools:3.0.3" already present on machine
2023-10-06T11:44:27Z [Normal] Created container block-cloud-metadata
2023-10-06T11:44:27Z [Normal] Started container block-cloud-metadata
2023-10-06T11:44:27Z [Normal] Container image "myregistory/jhtest:latest" already present on machine
2023-10-06T11:44:27Z [Normal] Created container notebook
2023-10-06T11:44:27Z [Normal] Started container notebook
Spawn failed: Server at http://10.244.4.110:8888/user/bob/ didn't respond in 30 seconds
and I found the message Running as root is not recommended. Use --allow-root to bypass
in the kubectl logs -f -n ns-z2jh jupyter-bob
3. Questions.
- IIUC, the cluster needs to run root privileges. Do I need to set
singleuser.uid
set to0
? - Do I need to use
extraEnv: GRANT_SUDO: "yes"
and--allow-root
options, If so, How do set it? - Is it possible to output the log in more detail? (I didn’t know the reason in the
kubectl logs -f -n ns-z2jh jupyter-bob
output)
4. Setting
hub:
db:
pvc:
storageClassName: nfs-client
config:
Authenticator:
enable_auth_state: true
JupyterHub:
authenticator_class: ldapauthenticator.LDAPAuthenticator
# https://github.com/manics/zero-to-jupyterhub-k8s-examples/blob/5212ad2440e9ccf3831b5957b80775e58581b232/ldap-singleuser/jupyterhub.yml
LDAPAuthenticator:
server_address: ldap.server
lookup_dn: True
bind_dn_template:
- uid={username},ou=users,dc=example,dc=com
user_search_base: "dc=example,dc=com"
user_attribute: uid
lookup_dn_user_dn_attribute: uid
escape_userdn: True
use_ssl: true
auth_state_attributes: ["uid", "uidNumber", "gidNumber", "homeDirectory"]
use_lookup_dn_username: False
extraConfig:
SpawnerCustomConfig: |
from ldapauthenticator import LDAPAuthenticator
from hashlib import md5
class LDAPAuthenticatorInfo(LDAPAuthenticator):
async def pre_spawn_start(self, user, spawner):
auth_state = await user.get_auth_state()
if not auth_state:
return
# https://github.com/jupyter/docker-stacks/blob/fde8f1eec3e70edf67560b5430545a22382334bf/base-notebook/start.sh#L41-L102
spawner.environment["NB_UID"] = str(auth_state["uidNumber"][0])
spawner.environment["NB_USER"] = auth_state["uid"][0]
spawner.environment["NB_GID"] = str(auth_state["gidNumber"][0])
c.JupyterHub.authenticator_class = LDAPAuthenticatorInfo
CustomHubConfig: |
c.JupyterHub.cleanup_servers = True
debug:
enabled: true
singleuser:
uid: 0
#extraEnv:
# GRANT_SUDO: "yes"
memory:
limit: 2G
guarantee: 2G
storage:
capacity: 100Mi
#homeMountPath: /home/jovyan
dynamic:
pvcNameTemplate: claim-{username}{servername}
storageAccessModes:
- ReadWriteMany
storageClass: nfs-client
volumeNameTemplate: volume-{username}{servername}
type: dynamic
image:
name: 'myrepository/jhtest'
tag: 'latest'
5. log
% kubectl logs -f -n ns-z2jh jupyter-bob
Defaulted container "notebook" out of: notebook, block-cloud-metadata (init)
[I 2023-10-06 11:49:28.543 ServerApp] Package jupyterhub took 0.0000s to import
[I 2023-10-06 11:49:28.549 ServerApp] Package jupyter_lsp took 0.0057s to import
[W 2023-10-06 11:49:28.549 ServerApp] A `_jupyter_server_extension_points` function was not found in jupyter_lsp. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-10-06 11:49:28.552 ServerApp] Package jupyter_server_terminals took 0.0035s to import
[I 2023-10-06 11:49:28.604 ServerApp] Package jupyterlab took 0.0514s to import
[I 2023-10-06 11:49:28.631 ServerApp] Package nbclassic took 0.0009s to import
[W 2023-10-06 11:49:28.632 ServerApp] A `_jupyter_server_extension_points` function was not found in nbclassic. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-10-06 11:49:28.632 ServerApp] Package nbgitpuller took 0.0005s to import
[I 2023-10-06 11:49:28.633 ServerApp] Package notebook_shim took 0.0000s to import
[W 2023-10-06 11:49:28.633 ServerApp] A `_jupyter_server_extension_points` function was not found in notebook_shim. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-10-06 11:49:28.633 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2023-10-06 11:49:28.635 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2023-10-06 11:49:28.635 JupyterHubSingleUser] Starting jupyterhub single-user server extension version 4.0.2
[I 2023-10-06 11:49:28.635 JupyterHubSingleUser] Using default url from server extension lab: /lab
[I 2023-10-06 11:49:28.637 ServerApp] jupyterhub | extension was successfully linked.
[W 2023-10-06 11:49:28.638 LabApp] 'extra_template_paths' was found in both NotebookApp and ServerApp. This is likely a recent change. This config will only be set in NotebookApp. Please check if you should also config these traits in ServerApp for your purpose.
[I 2023-10-06 11:49:28.640 ServerApp] jupyterlab | extension was successfully linked.
[W 2023-10-06 11:49:28.641 NotebookApp] 'extra_template_paths' was found in both NotebookApp and ServerApp. This is likely a recent change. This config will only be set in NotebookApp. Please check if you should also config these traits in ServerApp for your purpose.
[I 2023-10-06 11:49:28.642 ServerApp] nbclassic | extension was successfully linked.
[I 2023-10-06 11:49:28.643 ServerApp] nbgitpuller | extension was successfully linked.
[I 2023-10-06 11:49:28.816 ServerApp] notebook_shim | extension was successfully linked.
[I 2023-10-06 11:49:28.827 ServerApp] notebook_shim | extension was successfully loaded.
[I 2023-10-06 11:49:28.829 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2023-10-06 11:49:28.829 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2023-10-06 11:49:28.840 JupyterHubSingleUser] Updating Hub with activity every 300 seconds
[I 2023-10-06 11:49:28.840 ServerApp] jupyterhub | extension was successfully loaded.
[I 2023-10-06 11:49:28.841 LabApp] JupyterLab extension loaded from /usr/local/lib/python3.11/site-packages/jupyterlab
[I 2023-10-06 11:49:28.841 LabApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 2023-10-06 11:49:28.841 LabApp] Extension Manager is 'pypi'.
[I 2023-10-06 11:49:28.843 ServerApp] jupyterlab | extension was successfully loaded.
[I 2023-10-06 11:49:28.844 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
[I 2023-10-06 11:49:28.846 ServerApp] nbclassic | extension was successfully loaded.
[I 2023-10-06 11:49:28.851 ServerApp] nbgitpuller | extension was successfully loaded.
[C 2023-10-06 11:49:28.852 ServerApp] Running as root is not recommended. Use --allow-root to bypass.
_ _ _ _
| | | |_ __ __| |__ _| |_ ___
| |_| | '_ \/ _` / _` | _/ -_)
\___/| .__/\__,_\__,_|\__\___|
|_|
Read the migration plan to Notebook 7 to learn about the new features and the actions to take if you are using extensions.
https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html
Please note that updating to Notebook 7 might break some of your extensions.
7. Environment
- Z2JH: 3.0.3
- K8S: v1.27.4
- OS: Ubuntu 22.04
Best regards.