Deploy JupyterHub - myantandco/RA-BitnobiPilotJuly2020 GitHub Wiki

Bitnobi provides an interface with JupyterHub. This page describes how to deploy a JupyterHub and configure it to interface with Bitnobi.

This deployment is based on 'The Littlest JupyterHub' (TLJH) which is designed to support up to 100 users.

You will need a separate VM or server running Ubuntu 18.04 (or later) to host TLJH. This particular configuration installs TLJH directly onto a VM, but launches a separate docker container (jupyter/datascience-notebook) for each JupyterHub user and also a separate docker volume for holding their notebooks and other files. The TLJH processes are installed as ubuntu services and are started at boot time.

Log into the server and open a terminal window for the following steps.

1. Verify that Docker is installed

We will be using a docker image for the jupyter/datascience-notebook distribution and so docker community edition must be installed on your target server. To test if docker is installed type the command docker -v and it should return something like:

Docker version 19.03.5, build 633a0ea838

If you need to install docker, Here is the condensed sequence of commands. Note that you need to type y after some of them. :

sudo apt update

sudo apt install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
    
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
   
sudo apt update

sudo apt install docker-ce

sudo groupadd docker

sudo usermod -aG docker $USER

After executing the above commands, you need to logout and login again for the usermod change to take effect.

These were extracted from the following links:

2. Obtain Jupyter Notebook Docker Images

Pull the docker image for jupyter notebooks. The Bitnobi JupyterHub configuration uses the jupyter/datascience-notebook:

docker pull jupyter/datascience-notebook:latest

3. Install TLJH

The following steps for installing TLJH on a Ubuntu VM are based on: https://tljh.jupyter.org/en/latest/install/custom-server.html :

Install python3,python3-dev,curl and git:

sudo apt install python3 python3-dev git curl

Run installer. This script uses "admin" as the admin user name. This can take 5-10 minutes to complete:

curl -L https://tljh.jupyter.org/bootstrap.py | sudo -E python3 - --admin admin

4. Configuring TLJH for Bitnobi

Fetch the configuration scripts from dockerhub:

docker pull bitnobico/bitnobi-jupyterhub-scripts
docker run --name temp-container-name bitnobico/bitnobi-jupyterhub-scripts /bin/true
docker cp temp-container-name:/home/Bitnobi-V1 bitnobi-jupyterhub-scripts
docker rm temp-container-name
docker rmi bitnobico/bitnobi-jupyterhub-scripts

Run the configuration script:

cd bitnobi-jupyterhub-scripts
sudo ./bitnobi-config.sh

This will configure JupyterHub and generate a message similar to:

Here is your JupyterHub Admin API token to enter during Bitnobi init:
9a9669ca89dc5ae660491ff703aed0f348d05d2fbeffd1adc6de84a4de07d6f6

Please copy the API token into a temporary file.

5. Enabling HTTPS with a Self-signed Certificate

While in the bitnobi-jupyterhub-scripts folder run the following command to enable HTTPS:

sudo ./enable-ssl.sh

6. Login to the JupyterHub UI

Make sure that you port 443 is open on this server. Open a browser to https://hostname/ and you should see the JupyterHub login screen.

When we installed TLJH we specified the admin user to have the userid 'admin'. The default authenticator for TLJH will accept any password the first time that a new user logs in, and this becomes the password.

Now login as "admin" and set the password.

⚠️ **GitHub.com Fallback** ⚠️