Skip to content

Commit

Permalink
Add modify_pod_hook to jupyterhub_config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneTorap committed Nov 6, 2024
1 parent 169d927 commit dcede00
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions jupyterhub/files/hub/jupyterhub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@
)


def modify_pod_hook(spawner, pod):
if containers := pod.spec.containers:
values = [e.value for e in containers[0].env if e.name == "JUPYTERHUB_USER"]
if not values:
return pod

split_tenant_env = values[0].split("_")[1:]
tenant_env = "_".join(split_tenant_env)
_volume_mounts = containers[0].volume_mounts
if len(_volume_mounts) >= 2 and _volume_mounts[1].name == "jupyterhub-shared-tenant":
_volume_mounts[1].sub_path = tenant_env

return pod


c.KubeSpawner.modify_pod_hook = modify_pod_hook


def camelCaseify(s):
"""convert snake_case to camelCase
Expand Down

0 comments on commit dcede00

Please sign in to comment.