Open TomAugspurger opened 3 years ago
In kubespawner, we use https://github.com/jupyterhub/kubespawner/blob/master/kubespawner/spawner.py#L1395 to help deal with it. Maybe something like that can be added to dask-gateway?
Thanks, that looks better than the hacky regex I was cooking up :)
dask-gateway may not be the appropriate place for this. In this case, it’s just us (pangeo’s daskhub deployment) adding the label. If that method in kubespawner happened to be public, it’d be perfect for us, since kubespawner would be present on the machine where this code is executed :)
That said, there are dask-gateway deployments that aren’t jupyterhub deployments, who might benefit from a method like this, and wouldn’t have access to kubespawner.
On Nov 23, 2020, at 1:30 AM, Yuvi Panda notifications@github.com wrote:
In kubespawner, we use https://github.com/jupyterhub/kubespawner/blob/master/kubespawner/spawner.py#L1395 https://github.com/jupyterhub/kubespawner/blob/master/kubespawner/spawner.py#L1395 to help deal with it. Maybe something like that can be added to dask-gateway?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pangeo-data/pangeo-cloud-federation/issues/879#issuecomment-731979988, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKAOIQF3LI67UTI4TUTPKTSRIFQZANCNFSM4T45OSJQ.
The criteria required is that it's a valid DNS label - https://github.com/jupyterhub/kubespawner/blob/master/kubespawner/spawner.py#L1395.
import string
from escapism import escape
safe_chars = set(string.ascii_lowercase + string.digits)
safe_username = escapism.escape(self.user.name, safe=safe_chars, escape_char='-').lower()
This should work!
We add the JupyterHub username as a kubernetes label to the scheduler and worker pods at https://github.com/pangeo-data/pangeo-cloud-federation/blob/41b981403993a305d438cfddce5aa43f9d0ffdd5/pangeo-deploy/values.yaml#L104-L106. This aids in monitoring since we can easily see which JupyterHub user is using which Dask Gateway resources.
In another deployment, I noticed failures to start a scheduler when the JupyterHub username isn't a valid kubernetes label. Perhaps GitHub usernames are always valid so this hasn't come up, but we should set a model here for others copying our configuration options.