-
Notifications
You must be signed in to change notification settings - Fork 797
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
hub.extraEnv / singleuser.extraEnv in dict format to support k8s EnvVar spec #1757
hub.extraEnv / singleuser.extraEnv in dict format to support k8s EnvVar spec #1757
Conversation
527104c
to
9d1ad08
Compare
Note this commit relies on a KubeSpawner PR currently not merged. See jupyterhub/kubespawner#426.
a316b05
to
fd8c65d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think this is a good compromise!
I made some minor formatting suggestions based on https://zero-to-jupyterhub--1757.org.readthedocs.build/en/1757/reference/reference.html
Co-authored-by: Simon Li <orpheus+devel@gmail.com>
Thanks @manics! |
I consider this PR now ready for merge. @yuvipanda since you just looked at the KubeSpawner equivalent PR, perhaps you could have a look at this as well? Thank you @manics and @yuvipanda for the attention! ❤️ |
Thanks a lot for working on this, @consideRatio! |
Background
In short, specifying an environment variable for the JupyterHub pod or the user pods could only be done in a limited fashion that excluded specifying an environment variable that got its value from some Kubernetes ConfigMap/Secret or similar. This has only been only possible with intrusive workarounds. This PR closes #1103 and an associated KubeSpawner PR has already closed jupyterhub/kubespawner#306 (comment).
hub.extraEnv advanced syntax support
This PR enables
hub.extraEnv
to function with a format either exactly like Kubernetes EnvVar specification or a shorthand where aname: ...
is implied. This format is now also documented in the configuration reference (docs preview).singleuser.extraEnv advanced syntax support
This PR doesn't fully close #1103 because this only enables the new syntax support for
hub.extraEnv
but not also forsingleuser.extraEnv
. jupyterhub/kubespawner#426 is now merged which takes care of thesingleuser.extraEnv
part.Technical breakdown regarding singleuser.extraEnv
The Helm chart configuration
singleuser.extraEnv
propegates without issues toc.KubeSpawner.environment
which is defined in the Spawner base class, so it turned out that no changes were needed in this repo. Below are still some of the notes I made along the way to ensure that was the case and to develop the PR (jupyterhub/kubespawner#426) in KubeSpawner that fixed it over there.c.KubeSpawner.environment
or doing it throughsingleuser.extraEnv
should be fine even if we use the new syntax.environment
traitlet from the end of thejupyterhub.Spawner.get_env
function.get_env
function is then called to provide theenv
argument to themake_pod
function.make_pod
function use the the passed env vars once, that assuming support for new syntax should be able to get adummyKey1
with a value of{name: "MY_ENV", value: "my-value"}
passed to it.V1EnvVar
constructor allows for name/value/value_from, but is only used to pass a name/value combination rather than the possible name/valueFrom combination.Relevant references for this tech breakdown are the k8s api specs and the Python API for Kubernetes.
Discussion
name: ...
is implied. This is now supported.Todo
Related