Hi,
We are using enterprise gateway to spin up kernels in kubernetes. Enterprise Gateway is also running on Kubernetes.
We want to set custom environment variables in kernels while they are being created so that they are available when the kernel is ready to use.
I have followed Kernel Environment Variables — Jupyter Enterprise Gateway 3.1.0.dev0 documentation
While I am able to override existing KERNEL_ prefixed env vars like KERNEL_USERNAME and KERNEL_SPARK_CONTEXT_INIT_MODE, I am unable to create new environment var like KERNEL_USERID.
This is how my create kernel API call looks like
{ \"kernel\": { \"name\": \"py_3.7\"},\"env\": {\"KERNEL_USERID\": \"myuserid\"} }
A snippet of my enterprise gateway launcher script looks like
export EG_ENV_PROCESS_WHITELIST=KERNEL_USERID
exec jupyter enterprisegateway \
--log-level=${EG_LOG_LEVEL} \
--EnterpriseGatewayApp.unauthorized_users=[] \
--EnterpriseGatewayApp.env_process_whitelist=KERNEL_USERID \
--EnterpriseGatewayApp.env_whitelist = ['*'] \
--RemoteMappingKernelManager.cull_idle_timeout=${EG_CULL_IDLE_TIMEOUT} \
--RemoteMappingKernelManager.cull_interval=${EG_CULL_INTERVAL} \
--RemoteMappingKernelManager.cull_connected=${EG_CULL_CONNECTED} \
--RemoteMappingKernelManager.default_kernel_name=${EG_DEFAULT_KERNEL_NAME}
Am I missing something? Please let me know how to get it to work.
Thanks,
Debashis
Hi @debashis1982 - thanks for the question and welcome to Jupyter and Enterprise Gateway!
Which release of EG are you using? One of the last issues resolved prior to our 3.0.0 release was to address the fact that custom envs (including those prefixed with KERNEL_
) were not flowing to the kernel in Kubernetes environments.
I also notice that the env_whitelist
and env_process_whitelist
configurables are still in use, while these have been deprecated in favor of client_envs
and inherited_envs
, respectively.
Please try deploying EG 3.0.0 and if issues still persist (i.e., you find KERNEL_
envs not available to your kernel) please open an issue in the repository and we’ll be happy to take a closer look.
Take care,
Kevin.
Hi Kevin,
We are using EG version 3.0.0.dev0. Should I use a newer release?
I don’t see the changes done in Flow configured envs from client to kernel pod by kevin-bates · Pull Request #1164 · jupyter-server/enterprise_gateway · GitHub present in version 3.0.0.dev0
Thanks,
Debashis
We are using EG version 3.0.0.dev0. Should I use a newer release?
3.0.0.dev0 is not a release at all, but some snapshot captured during development. You should be using the 3.0.0 assets - helm charts, images, etc. Your image tags, assuming you’re using the OOTB images, should all be :3.0.0
and I suspect your tags are :dev
.
According to dockerhub, dev
images are 3 weeks old, while both 3.0.0rc1
and 3.0.0
are newer.
Using dev
-tagged images will always be risky and subject to changes.
I have tried EG version 3.1.0 with no success.
While the kernel is being launched EG logs looks like this
[I 2022-11-08 22:11:26.452 EnterpriseGatewayApp] Kernel started: 7a0eace8-67ba-4a43-af72-baccfe779253
[D 2022-11-08 22:11:26.452 EnterpriseGatewayApp] Kernel args: {'env': {'PATH': '/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'KERNEL_USERID': 'myuserId', 'KERNEL_USERNAME': 'root'}, 'kernel_headers': {}, 'kernel_name': 'py_3.7'}
But when I check the environment variables in the kernel, I do not see the env var KERNEL_USERID
I have not yet whitelisted KERNEL_USERID
. I thought I don’t have to
It worked after I added
- name: KERNEL_USERID
value: "{{ kernel_userid }}"
to the kernel’s kernel-pod.yaml.j2
Ok. I see. Could you please open an issue in the Enterprise Gateway repo? This extra config shouldn’t be necessary but will work. Please reply with the issue ID and we’ll dig deeper there.
Thanks,
Kevin.