Since there is no official guide on how to deploy nbgrader on Kubernetes, this repository provides a working example. The deployment is based on the Zero to Jupyterhub helm chart.
-
By default, nbgrader is not really meant to be deployed in an environment, where users cannot be uniquely identified by their UNIX user ids (UIDs). This is the case for Kubernetes, where each student has their own pod with the same user (jovyan, UID=1000). To overcome this limitation, we need to modify the default nbgrader exchange. The modified exchange is provided in the
nbgrader_exchange
folder, and also is part of all the docker images. See /nbgrader-exchange/README.md for more details. -
Courses are run as managed JupyterHub services. This means, that for each course there is a
singleuser
process running in the "hub" pod, which is only accessible by the instructors of the given course.NOTE: Currently all the courses have to be defined in the
values.yaml
file. This can be easily moved to a different location, if needed.Each course is bound to a specific port starting from
9000
. There is a headless kubernetes service, allowing the proxy to route traffic to any port of the "hub" pod. -
Students and instructors are distinguished by the groups they belong to. In order for the instructor to be able to access a course, he/she has to be a member of the group
formgrade-{course_id}
, wherecourse_id
is the name of the course. The same is true for the students, but they have to be a member of thenbgrader-{course_id}
group. There are separate images for students and instructors with different nbgrader extensions enabled. The image is selected based on the groups of the user.
Since we are using helm
, the deployment is pretty straightforward.
-
Install helm (see here for more details)
-
Clone this repository
git clone https://github.com/CERIT-SC/nbgrader-k8s cd nbgrader-k8s
-
Modify the
nbgrader-chart/values.yaml
file to suit your needsThe main values to change are:
exchange.size
- size of the exchange volumeexchange.storageClassName
- storage class to use for the exchange volumeingress
- ingress configurationjupyterhub.extraConfig.00-extra-config.PVC_STORAGE_CLASS
- storage class to use for user home volumesjupyterhub.hub.db.pvc.storageClassName
- storage class to use for the hub database volume
All the other JupyterHub related values can be found here
-
Download the dependencies
helm dependency update nbgrader-chart
-
Deploy the chart
helm install nbgrader nbgrader-chart -f nbgrader-chart/values.yaml