Skip to main content

Notebooks for the whole team,
a JupyterLab for each person.

JupyterHub is the multi-user hub of Project Jupyter: it authenticates each person, starts a dedicated server for them, with their own resources and storage, and takes the browser to it. Follow a login, from the address typed to the JupyterLab open in the user's Pod.

A multi-user hub starts, manages and routes access to several Jupyter servers, one for each user.

JupyterHub is that hub in TDP, and each user works in their own JupyterLab.

One entry point

Everything goes through the proxy

The proxy is the only public process. It takes the login to the Hub and each user's address to their server.

Who decides

The Hub coordinates

The Hub checks the login with the authenticator and asks the spawner for each person's server.

Each in their own place

One Pod per user

Each single-user server runs in its own Pod, with a volume and resources that belong only to that user.

On this page

See a login become a JupyterLab​

Ana opens JupyterHub in the browser and, a few steps later, is in her own JupyterLab. Press Play or move forward step by step. Underlined names lead to the Glossary.

BrowserWho comes in
BrowserAna, at the JupyterHub address
ProxyWho routes
ProxyThe only public entry point
HubWho decides
HubAccounts, login and servers
AuthenticatorValidates the login
KubeSpawnerCreates the server
User serverWhere the work happens
Ana's PodHer single-user server
PVCAna's files
JupyterLabThe working interface
Step 1 of 7

1 The browser reaches the proxy

Ana opens the JupyterHub address. The proxy, the only process exposed to the public, answers. As long as there is no route for her, the proxy forwards everything to the Hub, which sits behind it, at /hub.

  1. The browser reaches the proxy. Ana opens the JupyterHub address. The proxy, the only process exposed to the public, answers. As long as there is no route for her, the proxy forwards everything to the Hub, which sits behind it, at /hub.
  2. The authenticator checks the login. The Hub hands the login data to the authenticator. If it is correct, the authenticator returns the username: from here on, the Hub knows it is Ana.
  3. The spawner creates Ana's server. The Hub asks the spawner for a single-user server just for Ana. KubeSpawner creates a Pod for her, with the CPU and memory guarantee and limit defined for users.
  4. Ana's volume is mounted. On the first login, a PersistentVolumeClaim is created for Ana. On later logins, JupyterHub finds the existing PVC and mounts it on the new Pod. That is where her notebooks and files are kept.
  5. The proxy gets a route. When the server is ready, the Hub notifies the proxy: everything that arrives at /user/ana is now sent to Ana's Pod. In the browser, a cookie with an encrypted token is stored at /hub/.
  6. JupyterLab opens. The browser is redirected to /user/ana, and what answers now is Ana's single-user server, not the Hub. With JupyterLab installed, it is the interface the server opens.
  7. An idle server is shut down. A server with no activity for a configurable time is shut down by the idle culler: the Pod is removed, but the PVC stays. The in-memory state is lost, the saved notebooks remain, and at the next login a new Pod mounts the same volume.
Figure 1 - A JupyterHub login. The proxy is the only public entry point. The Hub validates the login, KubeSpawner creates the user's Pod with their volume, and the proxy starts routing the user's address to that Pod.

With JupyterLab open, each cell that runs follows the path shown in A cell in JupyterLab: JupyterHub delivers the server, and the server does the rest.

Architecture​

The proxy in front, the Hub behind it and a server for each user.

JupyterHub architecture: browser, proxy, Hub and user serversThe browser talks only to the proxy, the only public process. The proxy forwards /hub to the Hub and each /user/name to that user's Pod, according to the routing table that the Hub keeps up to date. The Hub brings together the authenticator, which validates the login, the KubeSpawner, which creates the Pods, the idle culler, which stops idle servers, and the database holding the Hub state. Each user Pod runs a single-user server, which opens JupyterLab, and mounts the PVC with that user's files.BrowserEach user at their own addressLogin/hub/loginAna/user/ana/labBruno/user/bruno/labProxyThe only public processRouting table/hub → Hub/user/ana → Ana's Pod/user/bruno → Bruno's Podconfigurable-http-proxyUser serversAna's PodSingle-user serverServer for Ana onlyJupyterLabThe interface, at /labPVCAna's filesBruno's PodSingle-user serverServer for Bruno onlyJupyterLabThe interface, at /labPVCBruno's filesHubAccounts, login and serversAuthenticatorValidates the loginKubeSpawnerCreates the PodsHub databaseUsers and serversIdle cullerStops idle serversBrowser requests, over HTTPThe Hub updates the proxy routesThe KubeSpawner creates the Pods
Figure 2 - JupyterHub architecture: the browser, the proxy with the routing table, the Hub with the authenticator, KubeSpawner, the idle culler and the Hub database, and a Pod for each user, with the single-user server, JupyterLab and the PVC. Underlined terms lead to the Glossary.

What the figure shows:

  1. The browser talks only to the proxy. Each user has their own address: in the figure, the login and the JupyterLab of Ana and Bruno.
  2. The proxy is the only public process. It forwards each request according to a routing table: /hub goes to the Hub, and each user's address goes to their server.
  3. The single-user servers each run in their own Pod, with that user's PVC mounted. Each server opens the user's JupyterLab.
  4. The Hub maintains the proxy's routing table and updates it through the proxy's REST API whenever a server starts or is shut down.
  5. The authenticator receives the login data, validates it, and returns the user name.
  6. KubeSpawner is the Hub's spawner on a Kubernetes cluster: it creates the servers' Pods.
  7. The Hub database stores the state of the Hub, with the users and the place where each user's server runs.
  8. The idle culler shuts down idle servers.

The JupyterHub components

The heart

Hub

Manages accounts and authentication, starts servers on demand and configures the proxy to take each user's address to the right server.

The gateway

Proxy

The only process that listens on a public interface. It forwards HTTP requests, including WebSockets, to the Hub and to the users' servers.

Who comes in

Authenticator

Receives the login data, validates it and returns the username. It is one of the two extension points of JupyterHub.

Where it runs

Spawner

Starts, monitors and shuts down each user's server. The other extension point. On a Kubernetes cluster, it is KubeSpawner.

Each user's address​

In the browser, the path says who answers. Click each part of the address.

Click each part of the address.

Servers prefix

Everything that starts with /user belongs to the user servers. The proxy takes each of these addresses to the corresponding user's server. The Hub, in turn, answers at /hub.

See in the Glossary
user — Servers prefix
Everything that starts with /user belongs to the user servers. The proxy takes each of these addresses to the corresponding user's server. The Hub, in turn, answers at /hub.
ana — Username
The name the authenticator returned at login. With Ana's server running, what answers at this address is her server, not the Hub. With the server stopped, the request goes back to the Hub, which can start it again.
lab — Interface
Inside the single-user server, /lab is the address of JupyterLab, the interface the server opens when JupyterLab is installed.

What each user gets​

One Hub for everyone; inside it, a Pod for each user; inside the Pod, the server that opens JupyterLab.

Level 1 of 4

Hub

The whole of JupyterHub, behind a single proxy: one Hub for all users, with the accounts, the login and the coordination of the servers.

  • ProxyThe only public entry point, with the routing table the Hub maintains.
  • Hub databaseThe Hub's state: the users and where each user's server runs. Besides usernames, it holds no sensitive information.
  1. Hub. The whole of JupyterHub, behind a single proxy: one Hub for all users, with the accounts, the login and the coordination of the servers.
    • Proxy. The only public entry point, with the routing table the Hub maintains.
    • Hub database. The Hub's state: the users and where each user's server runs. Besides usernames, it holds no sensitive information.
  2. User. A Hub account, recognized by the name the authenticator returns at login. Each user has their own server and their own address, at /user/ followed by the name.
    • Authenticator. Decides how each person proves who they are.
  3. Pod. The place where the user's server runs, created by KubeSpawner at login and removed when the server is shut down.
    • Guarantee and limit. The user's slice of CPU and memory: the minimum always available and the ceiling that cannot be exceeded.
    • PVC. The user's data. It remains after the Pod is removed and is mounted again at the next login.
    • NetworkPolicy. Rules that restrict the network ingress and egress of the users' Pods.
  4. Single-user server. The Jupyter server dedicated to the user, which answers at their address. With JupyterLab installed, JupyterLab is what it opens. From there on, the work proceeds as described on the JupyterLab page.
    • Jupyter Server. The JupyterLab backend, which takes the code in the cells to the kernels.
Figure 3 - Each level contains the next: the Hub serves many users, each user has a Pod, and the Pod runs the single-user server, which opens JupyterLab. Volume, resources and network rules go with the Pod.

JupyterHub or JupyterLab?​

One delivers the server to each person. The other is where the work happens.

Multi-user

JupyterHub

Authenticates users, starts and shuts down each user's server and takes each person to their own server.

The two work together

The single-user server opens JupyterLab, and JupyterLab, served by JupyterHub, gains in the File menu the options to log out and to go to the JupyterHub control panel.

Why JupyterHub​

Separate

One environment per person

Each user gets their own Jupyter environment, on a dedicated server, separate from the others.

Login

The organization's entry point

The authenticator is replaceable: local accounts, OAuth or the organization's single sign-on, without changing the rest of JupyterHub.

Resources

A predictable slice

CPU and memory guarantees and limits define how much of the cluster each user server can use.

Persistence

The work stays

Each user's volume remains when the server is shut down and is mounted again at the next login.

Scale

It follows the cluster

With KubeSpawner, the user servers are distributed across the nodes, and capacity grows or shrinks as nodes join and leave.

Administration

A REST API

The Hub, the users and the services are administered through a REST API.

Where it comes from

JupyterHub was created by Project Jupyter to serve many users with notebook servers. For Kubernetes clusters, the Zero to JupyterHub project maintains the JupyterHub Helm chart. JupyterHub is open-source software, under the modified BSD license.

In the TDP editions​

Available in the TDP editions
EditionVersionDocumentation
TDP Datacenter5.4.3TDP Datacenter components
TDP Kubernetes5.3.0 · chart tdp-jupyter 3.0.3Configuration in TDP Kubernetes

JupyterHub is the way to deliver JupyterLab to several users. In TDP Kubernetes, it is installed by the chart described below; in TDP Datacenter, it comes inside the Jupyterlab Notebook service, configured in Ambari under jupyterhub; see JupyterLab › On TDP Datacenter.

On TDP Kubernetes​

On TDP Kubernetes, JupyterHub is installed by the chart tdp-jupyter, which embeds the JupyterHub Helm chart from the Zero to JupyterHub project.

For this reason, the keys of the Hub, the proxy and the user servers are under tdp-jupyter, such as tdp-jupyter.hub, tdp-jupyter.proxy and tdp-jupyter.singleuser.

User servers

KubeSpawner creates a Pod for each user, named with the release name followed by notebook and the username, from the image in tdp-jupyter.singleuser.image. The image brings JupyterLab and the Python kernel with PySpark. See JupyterLab.

First login

The notebook image is large, and the chart pre-pulls it on the nodes that run notebooks, so the user server starts without waiting for the download. See JupyterLab Configuration.

Resources per user

The CPU and memory guarantee and limit of each user Pod are in tdp-jupyter.singleuser.cpu and tdp-jupyter.singleuser.memory.

Storage

Each user has a PVC, with the size set in tdp-jupyter.singleuser.storage.capacity. Without a StorageClass in tdp-jupyter.singleuser.storage.dynamic.storageClass, the cluster's default StorageClass applies.

Hub database

By default, the Hub keeps its state in SQLite, on a PVC. An external PostgreSQL can be enabled in TDP-Settings.externalDatabase.enabled.

Authentication

The Hub's authenticator is the class in tdp-jupyter.hub.config.JupyterHub.authenticator_class. The chart supports LDAP and Active Directory. See JupyterLab Security.

Idle servers

The idle culler of the Zero to JupyterHub chart comes enabled, in tdp-jupyter.cull.enabled: servers with no activity are shut down, and each user's PVC remains. The PVC (claim-<user>, with the notebooks) also remains after helm uninstall; see Uninstallation.

Proxy access

By default, the proxy is published as NodePort, in tdp-jupyter.proxy.service.type, which also accepts LoadBalancer and ClusterIP. Exposure through Ingress or Gateway API can be enabled in TDP-Settings.gateway.

Network and Spark

The NetworkPolicy of the user servers, in tdp-jupyter.singleuser.networkPolicy, restricts the ingress and egress of the Pods. The allowed egress rules and Spark in the notebooks are covered in JupyterLab.

OpenShift

The chart detects OpenShift at installation, but on OpenShift additional adjustments to the values apply, which automatic detection does not replace. See Jupyter Configuration.

Scenario: from data to model without leaving the platform​

Situation: the data team wants a model that classifies records by subject, such as tickets, orders, or documents, or that estimates a value, such as demand or risk. The training must use the data that the platform already integrates, without exporting copies outside it, and the result must reach the people who make decisions.

What TDP does: in the JupyterHub notebook, the PySpark in the image reads the integrated lakehouse table and trains the model with Spark MLlib, on the cluster itself. The training set is a version of the table, which time travel makes it possible to read again later to reproduce the result. The results go back to the lakehouse as a new table, which Trino queries and Superset publishes. The notebook stays on the user's volume, and the server is shut down when idle.

Effect: the model is born, runs, and leaves its result inside the platform: the same table that feeds the dashboards feeds the training, and each version used can be queried again.

Next steps​

Sources​

JupyterHub

JupyterHub Documentation

JupyterHub - Technical Overview

JupyterHub - Authenticators

JupyterHub - Spawners

JupyterHub - URL scheme

JupyterHub - Changelog

Zero to JupyterHub with Kubernetes

Zero to JupyterHub - The JupyterHub Architecture

Zero to JupyterHub - Customizing User Storage

Zero to JupyterHub - Customizing User Resources

Zero to JupyterHub - Customizing User Management

KubeSpawner

configurable-http-proxy

JupyterLab - JupyterLab on JupyterHub

Project Jupyter - About