I have 3 nodes configured with swarm (1 master, 2 workers)
I installed jupyterhub container on the master node. The aim is to run the user's notebook container on the worker side.
If we follow the default configuration, we obtain the container on the master node and it's not the aim.
I share with you an extract of my essay:
#swarm config
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
c.DockerSpawner.image = 'jupyter/minimal-notebook:x86_64-python-3.11.6'
c.DockerSpawner.mem_limit = '400M'
c.DockerSpawner.remove = False
notebook_dir = os.environ.get('DOCKER_NOTEBOOK_DIR') or '/home/jovyan'
#c.DockerSpawner.volumes = { '/home/{username}': notebook_dir }
# Set the base URL for JupyterHub
c.JupyterHub.base_url = '/'
# Use the Docker network defined in the `docker-compose.yml`
network_name = os.environ['DOCKER_NETWORK_NAME']
c.DockerSpawnerwork_name = network_name
# Set the Docker API to use the default socket
c.DockerSpawner.use_internal_ip = True
# Optional: Add additional volumes to persist data (such as user notebooks)
c.DockerSpawner.volumes = {
'/srv/jupyterhub/user-data': notebook_dir,
}
The container is created on the master node. In order to have it on worker side, we add:
c.DockerSpawner.extra_create_kwargs.update({
'constraints': ['node.role == worker'], # Ensure notebooks are only spawned on worker nodes
})
In this case, an error is raised:
Unhandled error starting user's server: ContainerApiMixin.create_container() got an unexpected keyword argument 'constraints'
I don't find useful info at DockerSpawner
API docs. Do you have any clues?
Thanks!