JupyterHub in Google’s Cloud Platform with Github OAuth and HTTPS using Helm. Part I

Simple guide to setup a JupyterHub using Helm.

saurs saurav
5 min readJan 16, 2019

JupyterHub(Jupyter Notebook) is fantastic platform but as much as it is awesome/fantastic it is also difficult to setup remotely and get going into a actual coding part.

No worries, Google’s Cloud platform and Helm are here to save you and your time!

Before diving into a guide, I will assume you know little or more about GCP, OAuth and Helm.

I have divided this guide into four sections. Sections are as given below:

  1. Create a cluster in GCP and connect to that cluster locally.
  2. Setup Helm and Install JupyterHub using Helm.
  3. Setup Github OAuth for Authentication.
  4. Setup HTTPS.

In Part I, we will be going through section1 & 2.

1. Create a cluster in GCP (Google Cloud Platform) and connect to that cluster locally.

In this part we will be setting up a kubernetes Cluster. Google Kubernetes Engine(GKE) give you simplest ways to set it up.

Note : You need to connect your payment method to your google cloud account to able to do all below steps.

  1. Go to console.cloud.google.com and log in.
  2. Go to and enable the Kubernetes Engine API.
  3. Download and install the gcloud command line tool at its downloads page. It will help you create and communicate with a Kubernetes cluster.
  4. Install kubectl (reads kube control), it is a tool for controlling Kubernetes
    clusters in general from your computer.

Go to terminal and enter :

gcloud components install kubectl

Now, lets create a project inside where we will create a kubernetes cluster. We will do these steps through GUI.

5. Go to and create a new project.

6. Go to Kuberenetes Engine Menu or simply search a term kubernetes engine.

7. Click a create cluster button as shown in picture.

Click create cluster.

8. Select a standard cluster. Change other configuration according to your needs then click a create button to create a cluster.

Click create button which lies at bottom

It will take minute or more to create a cluster.

9. Now to connect to a created cluster locally click connect button.

click a connect button of cluster you have created. In this example i created a cluster name test

10. Copy a statement in Command-line access block and run it to your command line.

Output :

Fetching cluster endpoint and auth data.
kubeconfig entry generated for test.

Congratulations, you have created a cluster and connected it from your computer.

2. Install and setup Helm and Install JupyterHub using Helm.

In this part we will setup helm in both server and client and install JupyterHub using Helm and finally run JupyterHub.

Install Helm

Rum below Helm’s installer script in a terminal:

curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash

Setup Helm

  1. After installing helm on your machine, initialize Helm on your Kubernetes cluster:
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller

2. Initialize helm and tiller.

helm init --service-account tiller --wait

3. Ensure that tiller is secure from access inside the cluster:

kubectl patch deployment tiller-deploy --namespace=kube-system --type=json --patch='[{"op": "add", "path": "/spec/template/spec/containers/0/command", "value": ["/tiller", "--listen=localhost:44134"]}]'

4. You can verify that you have the correct version and that it installed properly by running:

helm version

And output should be something like below :

Client: &version.Version{SemVer:"v2.11.0", GitCommit:"2e55dbe1fdb5fdb96b75ff144a339489417b146b", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.11.0", GitCommit:"2e55dbe1fdb5fdb96b75ff144a339489417b146b", GitTreeState:"clean"}

Congratulations, Helm is now set up!

Prepare configuration file

Now that we have set Kubernetes cluster and Helm up, we can proceed by using Helm to install JupyterHub and related Kubernetes resources using a Helm chart. We have to make a config.yaml file consisting of all the configuration inorder to run jupyterhub. So, lets prepare config.yaml file.

  1. Generate a random hex string representing 32 bytes to use as a security token. Run this command in a terminal and copy the output:
openssl rand -hex 32

2. Create and start editing a file called config.yaml.

nano config.yaml

3. Write the following into the config.yaml file but instead of writing <RANDOM-HEX> paste the generated hex string you copied in step 1.

proxy:
secretToken: "<RANDOM_HEX>"

4. Save the config.yaml file.

Install JupyterHub

  1. Run to Install JupyterHub chart
helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/
helm repo update

This should show output like:

Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "stable" chart repository
...Successfully got an update from the "jupyterhub" chart repository
Update Complete. ⎈ Happy Helming!⎈

2. Run this command from directory that contains your config.yaml:

# Suggested values: advanced users of Kubernetes and Helm should feel
# free to use different values.
RELEASE=jhub
NAMESPACE=jhub
helm upgrade --install $RELEASE jupyterhub/jupyterhub \
--namespace $NAMESPACE \
--version 0.7.0 \
--values config.yaml

It will take a while to create pods.

3. Find the IP we can use to access the JupyterHub. Run the following command until the EXTERNAL-IP of the proxy-public service is available like in the example output.

kubectl get service --namespace jhubNAME           TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)        AGE
hub ClusterIP 10.51.243.14 <none> 8081/TCP 1m
proxy-api ClusterIP 10.51.247.198 <none> 8001/TCP 1m
proxy-public LoadBalancer 10.51.248.230 104.196.41.97 80:31916/TCP 1m

4. To use JupyterHub, enter the external IP for the proxy-public service in to a browser. JupyterHub is running with a default dummy authenticator so entering any username and password combination will let you enter the hub.

Congratulations! Now that you have basic JupyterHub running

The End Of Part I

All the above steps can be found in here with more details. I just outlined a main things. In Part II, we will setup a GitHub Authentication into our JupyterHub.

Any queries?, mail me at saurssaurav33@gmail.com

--

--