/

hasura-header-illustration

Using Kubernetes to power Asia’s largest MOOC

Kubernetes helps MOOC students practice web development and deployment using just a browser.

Last year, we ran a MOOC on application development called IMAD (Introduction to Modern Application Development) which saw over 83,000 registrations.

The application design

To begin with, we were sure that asking students to use their machines for programming would not be a good idea. The audience for an online course would have huge variations in terms of hardware, operating systems etc. Providing instructions or guidance for multiple platforms throughout the course would have been an operational nightmare.

But, everybody has a web browser, and we decided to make use of it.

As our main focus was on developing web applications, an immediate requirement of a platform for students to publish their applications also became apparent.

At Hasura, we had been using Kubernetes for deploying production workloads for some time then. Since, we would have needed to provide isolated runtimes for all our students to build and deploy their applications, it became clear to us from the very beginning that Kubernetes would be the way to go.

Our plan was to create a web application which lets users write code using a browser and deploy it in real-time. After comparing a few different models, we decided to create a Kubernetes deployment and service for each user, hosting their code on GitHub and running it inside a nodeJS container. Each user would be given a subdomain and all requests were to be reverse proxied to the corresponding Kubernetes service using nginx.

The application workflow

A user logs in using GitHub and, using GitHub API v3, we fork a template repository into the user’s GitHub account. Files from this repository are then fetched for the user to edit using Ace Editor. All edits made to the files are committed to the user’s repository. We eliminated the need to use our own storage backend for users’ code as well as gave all students, mostly first time developers, a taste of GitHub by doing this. When a user triggers a deployment, our API server creates a deployment and a service on a dedicated Kubernetes cluster. The deployment has a gitRepo volume with the user’s repository, thereby pulling the user’s latest code on to a pre-built nodeJS docker image. An nginx daemonset, running on all nodes, directs incoming HTTP traffic to the user’s containers based on the subdomain, thereby serving their web-app.

Overall architecture of the system

The Kubernetes cluster was initially hosted on Microsoft Azure and then migrated to Google Container Engine (effortlessly).

The Result

Over the duration of the course, we saw participation from a diverse set of students — college students, working professionals, stay-at-home mothers and educators, often with little or no background in computer science or application development experience. A mind boggling ~10000 apps were built!

The students also had a lot of good things to say about their first experience with developing applications (you can read more about it here):

None of this would have been easy without Kubernetes (and the Hasura platform, of course).

Blog
04 Apr, 2017
Email
Subscribe to stay up-to-date on all things Hasura. One newsletter, once a month.
Loading...
v3-pattern
Accelerate development and data access with radically reduced complexity.