Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JUPYTERHUB env variables for init containers #855

Open
lahwaacz opened this issue Sep 28, 2024 · 3 comments
Open

JUPYTERHUB env variables for init containers #855

lahwaacz opened this issue Sep 28, 2024 · 3 comments

Comments

@lahwaacz
Copy link

Proposed change

I would like to do some user-specific configuration in init containers. For this I need the current username on JupyterHub, which is normally set in the JUPYTERHUB_USER environment variable. However, it seems that init containers of the singleuser pod don't get any of the JUPYTERHUB_* environment variables.

Alternative options

None?

Who would use this feature?

(Optional): Suggest a solution

@jabbera
Copy link

jabbera commented Oct 11, 2024

We pass this in using a custom hook. For us this wouldn't remove our requirement for the hook so it's not a big deal, but it might work for you.

@lahwaacz
Copy link
Author

@jabbera Can you elaborate? Can you give an example of the custom hook, ideally?

@jabbera
Copy link

jabbera commented Oct 21, 2024

@lahwaacz During configuration you can set:


c.Spawner.pre_spawn_hook = Your_pre_spawn_hook

async def Your_pre_spawn_hook(self, spawner: KubeSpawner) -> None:
            spawner.init_containers[0]["env"] += [
                V1EnvVar(name="JUPYTERHUB_USER", value=spawner.user.name),
                V1EnvVar(name="JUPYTERHUB_SERVER_NAME", value=spawner.name),
            ]

I agree it's silly these are not set by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants