DEV Community

Cover image for Try Jupyter Hub on GKE with dummy authentication
Mostafa Gazar
Mostafa Gazar

Posted on • Edited on

Try Jupyter Hub on GKE with dummy authentication

Create a new cluster

export cluster_name=jhub-cluster
export cluster_zone=us-central1-a

gcloud container clusters create $cluster_name \
    --machine-type=n1-standard-2 \
    --num-nodes 2 \
    --enable-autoscaling --min-nodes 0 --max-nodes 6 \
    --zone $cluster_zone
Enter fullscreen mode Exit fullscreen mode

Set kubectl locally

gcloud container clusters get-credentials $cluster_name --zone $cluster_zone
Enter fullscreen mode Exit fullscreen mode

Install helm and set it up

brew install kubernetes-helm
Enter fullscreen mode Exit fullscreen mode

Setup Tiller Service account

# Make tiller an admin, do not do so in production
kubectl create clusterrolebinding user-admin-binding \
   --clusterrole=cluster-admin \
   --user=$(gcloud config get-value account)
kubectl create serviceaccount tiller --namespace kube-system
kubectl create clusterrolebinding tiller-admin-binding \
   --clusterrole=cluster-admin \
   --serviceaccount=kube-system:tiller

helm init --service-account=tiller
helm repo update

# 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"]}]'
Enter fullscreen mode Exit fullscreen mode

Verify helm and tiller were installed properly

By checking the client and server versions. You might need to wait a minute or two while the tiller pod is in the running state.

helm version
Enter fullscreen mode Exit fullscreen mode

You should get a matching client and server versions like:
helm version run


Make Helm aware of the JupyterHub Helm chart repository

So you can install the JupyterHub chart from it, https://zero-to-jupyterhub.readthedocs.io/en/latest/setup-jupyterhub.html

helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/
helm repo update
Enter fullscreen mode Exit fullscreen mode

Create JupyterHub config file

nano config.yaml

# proxy:
#   secretToken: "eb4e1c0f2a77bacc63c1a1ada95507f5b551d53e18b204df30bb23966>
#
# auth:
#   type: dummy
#   dummy:
#     password: 'password'
#   whitelist:
#     users:
#       - user1
#       - user2
#       - admin
Enter fullscreen mode Exit fullscreen mode

Now install the chart configured by your config.yaml

RELEASE=jhub
NAMESPACE=jhub

helm upgrade --install $RELEASE jupyterhub/jupyterhub \
  --namespace $NAMESPACE  \
  --version=0.8.2 \
  --values config.yaml

# Get the external IP to access JupyterHub
kubectl get service --namespace jhub
Enter fullscreen mode Exit fullscreen mode

Share it and get it in touch, my Twitter DMs are open!

Top comments (0)