Coder Social home page Coder Social logo

mhwasil / jupyterhub-on-kubernetes Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 98 KB

Jupyterhub deployment with Kubernetes (K8s) on Google Kubernetes Engine (GKE). This project is part of DigiKlausur project to deploy jupyterhub on Kubernetes (Google Kubernetes Engine) for teaching.

License: MIT License

Python 35.87% Shell 30.74% Dockerfile 29.25% Makefile 4.14%
jupyterhub jupyterhub-deployment jupyterhub-kubernetes-spawner kubernetes-deployment kubernetes jupyterhub-tutorial

jupyterhub-on-kubernetes's Introduction

Jupyterhub deployment with Kubernetes (K8s) on Google Kubernetes Engine (GKE). This project is part of DigiKlausur project project to deploy jupyterhub on Kubernetes (Google Kubernetes Engine) for teaching. We switched from a single server jupyterhub to Kubernetes since we have a big class consisting of almost 300 students. This deployment is currently running for a bachelor course WahrscheinlichkeitstheorieUndStatistik winter 18/19, Hochschule Bonn-Rhein-Sieg.

The installation tutorial is mostly based on the zero-to-jupyterhub documentation.

Basic installation

  • Requirements
    • A Google Cloud account (you may want to use 300$ free credit from google)
    • Enabling GKE
      • Visit the Kubernetes Engine page in the Google Cloud Platform Console.
      • Create or select a project.
      • Wait for the API and related services to be enabled. This can take several minutes.
      • Make sure that billing is enabled for your project.
      • more https://cloud.google.com/kubernetes-engine/docs/quickstart
    • Have a little understading on what Kubernetes, Node, Pod, Helm, Docker
  • Installing jupyterhub on GKE
    • Open cloud shell on the top right
    • Install kubectl: gcloud components install kubectl
    • Set the zone
      • ZONE=europe-west1-b
      • gcloud config set compute/zone $ZONE
    • Create the cluster
      • CLUSTERNAME=e2-datahub
      • gcloud beta container clusters create $CLUSTERNAME --machine-type n1-standard-1 --num-nodes 2 --disk-size 50 --cluster-version latest --node-labels hub.jupyter.org/node-purpose=core
      • check the nodes are ready: kubectl get node
    • Create cluster admin
      • EMAIL=[email protected]
      • kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=$EMAIL
    • Install helm
    • Secure helm
      • 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"]}]'
    • Install jupyterhub with helm
      • Create secretToken for jupyterhub and create config.yaml
        • openssl rand -hex 32
        • Create config.yaml and put the secretToken in there
      • Add jupyterhub to helm
      • Install jupyterhub
        • Create RELEASE and NAMESPACE
          • RELEASE=mas-jhub
          • NAMESPACE=mas-jhub
        • Install jupyterhub
          • helm upgrade --install $RELEASE jupyterhub/jupyterhub --namespace $NAMESPACE --version 0.7.0 --values config.yaml
    • Updating the config
      • helm upgrade $RELEASE jupyterhub/jupyterhub --namespace $NAMESPACE --version 0.7.0 --values config.yaml

Advanced guide

  • Creating image and push it to gcr.io
    • Create a docker file as in the directory user-image
    • Modify the Google project name in Makefile
    • Add some images and packages in Dockerfile if needed
    • Create docker file by: make
    • Check docker file present in your local pc or google cloud shell by: docker images
    • Push docker file to gcr.io: gcloud docker โ€” push image_name
  • Authentication
auth:
  type: github
  github:
    clientId: "4c4b0149fbee3d1eqw"
    clientSecret: "be560598fa89096f2e02f1ee72442d9b0eb277d5"
    callbackUrl: "http://notebooks.h-brs.de/hub/login"
  • Automatic https
proxy:
  secretToken: ""
    https:
      hosts:
	- notebooks.mydomain.org
      letsencrypt:
	contactEmail: [email protected]
  • If https does not work, eg. the port is not open, try specifying the loadBalancer IP
  • nbgitpuller
singleuser:
  lifecycleHooks:
    postStart:
      exec:
	command: ["gitpuller", "https://github.com/username/my-repo", "master", "my-repo"]
  • Modifying load balancer
    • Tweaking load balancer ip is useful when https port may not be open, and if it is the case create new ip and attach that ip to the load balancer.
    • You can change the load balancer ip by removing the old one and create new static ip and attach that new ip to the load balancer
    • Tell config.yaml this new ip
proxy:
  secretToken: ""
  service:
    type: LoadBalancer
    loadBalancerIP: a.b.c.d
  • Configure node pools for core and user. This config has been used in the Binder configuration.
    • a "core" pool, which runs the hub, etc.
    • a "user" pool, where user pods run.
    • example: "hub.jupyter.org/node-purpose": "core" and "user"
    • More issue can be found here
  • Let's encrypt automatic https update
    * kubectl exec autohttps-6cc94589d-8fdxj -c kube-lego reboot -n prod
    * kubectl exec autohttps-6cc94589d-8fdxj -c nginx reboot -n prod

jupyterhub-on-kubernetes's People

Contributors

mhwasil avatar

Watchers

 avatar

Forkers

sgouda0412

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.