Autoscaling script for JupyterHub on top of Kubespray


January 20, 2021

I think the most reliable way of deploying Kubernetes on Openstack is Kubespray, see my latest tutorial about it focused on Jetstream.

The main issue with this strategy, compared to using Magnum, is that it is not supported by the Cluster Autoscaler, so we don’t have an automatic way of scaling up and down the deployment based on load.

For testing purposes I developed a small script that implements this, just to set the expectations, I called it hacktoscaler.

It is a bash script that runs on a server (ideally will deploy inside Kubernetes but for now is external), every minute:


  • All that is needed to run Kubespray, see my latest tutorial linked above
  • Symlink the kubespray folder inside the hacktoscaler folder

How to run

You should have already checked out my jupyterhub-deploy-kubernetes-jetstream repository, cd into the hacktoscaler folder.

Check its configuration by editing and then launch it:


Then you can simulate some users to trigger the scaling (this requires hubtraf):


After this you should be able to see the logs of what the hacktoscaler is doing.

If you weren’t already warned by the name of this script, USE AT YOUR OWN RISK, and good luck.