As an example, I was running into a bug that made kubespawner just not work for users with usernames starting with
-. Now, this needs to be fixed properly in kubespawner, but the student encountering this issue had a deadline! How to fix this?
From the error message, I know that the issue was us setting a label with the username on the pod, and that not being escaped properly. Looking through the code, I also discovered the exact line causing the issue. Since I don’t use the labels for anything useful, I just needed to get rid of it.
You can specify python you want to run as part of config via hub.extraConfig, and this can be used to actually make a new spawner class! So you inherit from KubeSpawner, override what you want, and tada!
In our case, the config ended up something like this:
hub: extraConfig: 01-no-labels: | from kubespawner import KubeSpawner class CustomSpawner(KubeSpawner): def _build_common_labels(self, extra_labels): labels = super()._build_common_labels(extra_labels) # Until https://github.com/jupyterhub/kubespawner/issues/498 # is fixed del labels['hub.jupyter.org/username'] return labels
This removes the username label, and solves my problem! I link it to the kubespawner issue, so I can remove this customization when the issue is fixed.
Hope this helps folks!