I'm using the Zero to Jupyterhub Helm package in order to deploy Jupyterhub into our kubernetes cluster. The individual notebook images need some extra environment variables (database connection information, mainly), and I'd like them to draw the values from an existing secret in the k8s namespace. How do I do this?
The naive approach of using the following config doesn't work:
singleuser:
extraEnv:
SECURE_ENVIRONMENT_VARIABLE:
valueFrom:
secretKeyRef:
name: secret
value: key
It results in SECURE_ENVIRONMENT_VARIABLE
being set to map[valueFrom:map[secretKeyRef:map[name:secret value:key]]]
.
I've also tried using singleuser.extraConfig
to set c.KubeSpawner.extra_container_config
as per the KubeSpawner config docs, but if you use that to set env
it apparently overwrites the existing environment variables, which breaks the system:
extraConfig: |
c.KubeSpawner.extra_container_config = {
"env": [
{
"name": "SECURE_ENVIRONMENT_VARIABLE",
"value": "test" # even a hardcoded value results in the container failing
}
]
}
For the record, I'd be fine with creating the deployment .yaml via helm upgrade --debug --dry-run
and editing that manually if necessary, I just can't figure out how to get this information onto the dynamically spawned pods.