How can I set a custom content manager with docker-stacks/base-notebook, deployed via Z2JH on K8s?

Hey all,

I’m trying to deploy the base-notebook docker image (with JupyterLab 3.2.1) using zero-to-jupyterhub with kubernetes v1.2.0. I want to use a custom content manager, which I’ve configured in /etc/jupyter/jupyter_notebook_config.py (and /etc/jupyter/jupyter_server_config.py, not sure which one is used) by setting c.ServerApp.contents_manager_class = CustomContentManager. When I run the base-notebook docker image locally, the custom content manager works just fine, but when I deploy it through zero-to-jupyterhub with kubernetes, the custom content manager isn’t used.

Logging statements confirm that the configuration is being loaded:

Mon, Apr 4 2022 4:22:16 pm  [D 2022-04-04 23:22:16.129 LabApp] Config changed: {'NotebookApp': {...}, 'ServerApp': {..., 'contents_manager_class': <class 'MyCustomContentsManager'>, ...}, 'SingleUserNotebookApp': {...}, 'Application': {...}}

So it looks like the configuration is correctly set, which makes sense - the base-notebook docker image works perfectly when I run it on my local machine. It’s just when I deploy it through Z2JH that the contents manager doesn’t show the content that I expect it to.

I feel like I’m missing something here - should I be configuring the SingleUserNotebookApp instead? Has anyone run into this issue?

1 Like

The default on Z2JH 1.* is jupyter-notebook, so it sounds like c.ServerApp is being ignored. You could try

singleuser:
  extraEnv:
    JUPYTERHUB_SINGLEUSER_APP: "jupyter_server.serverapp.ServerApp"

@manics Thank you so much for the advice! For reasons that aren’t exactly clear to me adding this environment variable to singleuser.extraEnv didn’t work; the deployment process is complicated and somehow it wasn’t appearing in the deployment yaml generated from the Z2JH helm charts. But I managed to get it into the environment elsewhere in our configuration, and it allowed my ServerApp settings to work. Thank you!