[Feature/Config] Enable shared custom configuration between JupyterLab and JupyterHub via Helm

Description:
We need a way to define custom configurations in the Helm values.yaml (or a custom config.yaml) that can be accessed by both JupyterHub and JupyterLab instances running in the same Kubernetes cluster. This is critical for maintaining consistent settings (e.g., feature flags, API endpoints, or environment-specific variables) across all user sessions.

thanks!

what sort of “custom configurations” are these, and how are they made available? If they are loaded as environment variables, perhaps the simplest way is to set them as environment variables in the Hub container and then pass them to singleuser containers via Spawner.env_keep.

More generally, you can create a configmap with your config (outside the jupyterhub chart) and then mount this as environment variables / volumes in both singleuser and hub.

If they are files, you might use hub.extraFiles and singleuser.extraFiles.

If you want to place the same file in both and avoid duplicating yaml content, you can use a yaml anchor and alias to avoid duplication:

hub:
  extraFiles:
    hub-thing: &common-file
      mountPath: /etc/some-config.json
      data:
        key: value
      

singleuser:
  extraFiles:
    # copies hub.extraFiles.hub-thing
    singleuser-thing: *common-file

(the same applies to any common yaml structure, such as a volume mount, environment variables, etc.)

2 Likes

Thank you for your quick and clear response! My use case is a bit special: I’ve heavily customized ​JupyterHub and ​JupyterLab (including extensions like context-menu), and now I need to reference the ​same external API URL in multiple places:

  1. Python files (e.g., notebook utilities or backend logic).
  2. ​**index.tsx** (frontend React components in JupyterLab extensions).
  3. JupyterHub shared templates (e.g., HTML/JS under /usr/local/share/jupyterhub/templates/).

Currently, I’m hardcoding the URL everywhere, which is error-prone and hard to maintain. ​Is there a simple, centralized way to define this URL once and access it across all these contexts?

Ideal Solution Requirements:

  • Single source of truth (e.g., Helm values.yaml, ConfigMap, or environment variable).
  • Accessible in all three contexts:
    • Python (os.environ or config file).
    • TypeScript/React (e.g., injected at build time or fetched dynamically).
    • JupyterHub templates (e.g., via template variables).

(Bonus if it works with both Helm deployments and local development!) :heart: