jupyterhub-secrets

by jupyterjsc

Helm chartv0.1.3App 1.0.0Verified publisher

ExternalSecrets for a JupyterHub

About this chart

JupyterHub secrets

This standalone chart creates comparison ExternalSecrets for a JupyterHub. It does not replace or reconfigure existing Secret consumers. Install it separately from jupyter-hub-customizations and set global.namespace to the hub namespace (the default is default). The referenced SecretStore must be accessible in that namespace.

ExternalSecrets

Configure the Vaultwarden item IDs in the desired order:

secretStores:
  default_slug: jupyterjsc
  slug:
    metrics:
      git_repo: default
      git_token: default
      git_token_name: default
    metrics_codebase:
      git_repo: default
    frontend:
      git_blocklist_repo: default
    generic:
      loki_hash_key: default
    tunnel:
      username: default
    outposts:
      vaultwarden-item-id-1:
        name: default
        url: default
  fields:
    name: bitwarden-fields
    kind: ClusterSecretStore
  ids:
    generic: vaultwarden-generic-item-id
    tunnel: vaultwarden-tunnel-item-id
    metrics: vaultwarden-metrics-item-id
    metrics_codebase: vaultwarden-metrics-codebase-item-id
    user_kpi_codebase: vaultwarden-user-kpi-codebase-item-id
    static_hub: vaultwarden-static-hub-item-id
    reservation_keypair: vaultwarden-reservation-keypair-item-id
    unity: vaultwarden-unity-item-id
    jhub_frontend: vaultwarden-frontend-item-id
    outposts:
      - vaultwarden-item-id-1
      - vaultwarden-item-id-2

Each field uses secretStores.default_slug unless its item type and field name have an override under secretStores.slug. Outpost overrides are keyed by Vaultwarden item ID, so different outposts can use different suffixes. For example, metrics.git_repo: default selects git_repo_default, while the unoverridden git_branch selects git_branch_jupyterjsc. The suffix default is just a selectable value, not automatic fallback: missing or empty selected fields are not retried with another suffix. A missing selected field causes ESO reconciliation to fail. Suffixes must be nonempty lowercase letters or digits, optionally separated by hyphens.

Each ExternalSecret is generated only when its corresponding Vaultwarden ID is set. es-generics combines the optional generic, tunnel, and outposts sources and is generated when at least one of them is configured.

Set secretStores.refreshInterval to control how often ESO refreshes every generated ExternalSecret; it defaults to 15m0s.

All fields now use suffixes, including fields previously read without one. Before deploying, migrate the existing Vaultwarden fields and configure any overrides.

Outposts and generics

Each outpost item must expose these custom fields through the configured store, with the suffix selected as described above:

FieldValue
username_<suffix>, password_<suffix>Plain-text credentials for this outpost.
authKey_<suffix>The complete, unique Secret key, e.g. AUTH_OUTPOSTKUBEJSCCLOUD. It must start with AUTH_OUTPOST and contain only uppercase letters, digits and underscores.
initsystem_<suffix>The text true or false.
name_<suffix>, url_<suffix>Initial system name and flavor URL. Both fields must exist even when initsystem is false; when it is true they must be nonempty and cannot contain semicolons.

With at least one outpost, generic, or tunnel ID, ESO creates es-generics in global.namespace. Each authKey contains base64(username:password). The three OUTPOST_FLAVOR_INITIAL_SYSTEM_NAMES, OUTPOST_FLAVOR_INITIAL_SYSTEM_TOKENS, and OUTPOST_FLAVOR_INITIAL_SYSTEM_URLS values contain semicolon-separated entries for items marked true, in the configured order. If none are marked true, the three values are empty. ESO manages Kubernetes Secret encoding separately, so the application receives the base64 credential string after Kubernetes decodes the Secret.

When generic is set, the corresponding Vaultwarden item must expose these nonempty plain-text custom fields:

FieldOutput Secret key
loki_hash_key_<suffix>LOKI_HASH_KEY, containing base64(loki_hash_key)

When tunnel is set, its separate shared Vaultwarden item must contain username_<suffix> and password_<suffix>. The selected nonempty plain-text values produce TUNNEL_AUTHENTICATION_TOKEN, containing base64(username:password). The tunnel service in its own namespace must retrieve the shared Vaultwarden item independently; Kubernetes Secrets cannot be shared across namespaces.

If there are no outpost IDs, the three initial-system values are empty. If generic or tunnel is unset, its corresponding key is omitted.

This template requires an ESO v2 template engine with Sprig's fail function (supported in ESO v2.0.1, but not v2.15.0). Check compatibility before upgrading ESO. Invalid fields and duplicate authKey values fail reconciliation. ESO's default ownership replaces the target Secret's data, so do not use an existing es-generics that must retain other keys. With no outpost, generic, or tunnel ID, no ExternalSecret is generated.

Frontend and metrics

jhub_frontend selects the existing frontend item. Its six custom field names are the lowercase versions of the output Secret keys, with the selected suffix appended, e.g. git_blocklist_repo_default.

Set secretStores.frontend.share_overlays: false to omit the share_overlays_git_branch and share_overlays_git_repo fields (keys SHARE_OVERLAYS_GIT_BRANCH and SHARE_OVERLAYS_GIT_REPO). They are fetched and applied by default. When enabled, their suffixes can be overridden with slug.frontend.share_overlays_git_branch and slug.frontend.share_overlays_git_repo.

When metrics is set, ESO creates es-hub-metrics with GIT_BRANCH, GIT_REPO, GIT_TOKEN and GIT_TOKEN_NAME. The item must provide git_branch_<suffix>, git_repo_<suffix>, git_token_<suffix> and git_token_name_<suffix>. These values are copied unchanged.

Set secretStores.metrics.subdir: true to also read git_subdir_<suffix> and include GIT_SUBDIR; it is omitted by default. Its suffix can be overridden with slug.metrics.git_subdir.

When metrics_codebase is set, ESO creates es-hub-metrics-codebase with the same four Git keys and a required GIT_SUBDIR, read from git_subdir_<suffix>. Use slug.metrics_codebase for per-field suffix overrides. Its item ID and suffix overrides are independent of metrics.

When user_kpi_codebase is set, ESO creates es-hub-user-kpi-codebase with the same five Git keys as the metrics codebase Secret. Configure independent per-field suffixes under slug.user_kpi_codebase.

The bundled jupyter-metrics and jupyter-user-kpi charts reference hub-<suffix>, not the es- Secrets; creating these Secrets does not change those consumers.

Static hub values

Set secretStores.ids.static_hub to the Vaultwarden item ID. Store the complete multiline Helm values YAML in values_<suffix>, for example values_jupyterjsc. The suffix comes from default_slug, or from slug.static_hub.values if set. ESO creates es-static-hub-secret with a single values.yaml key containing the unchanged YAML. Kubernetes represents Secret data as base64 in its API; do not pre-encode the Vaultwarden field, since Fleet needs the decoded YAML.

For Fleet's downstream-cluster helm.valuesFrom, refer to that key:

helm:
  valuesFrom:
    - secretKeyRef:
        name: es-static-hub-secret
        namespace: your-hub-namespace
        key: values.yaml

The Secret must already exist in the downstream cluster before Fleet deploys a bundle that consumes it.

Reservation SSH keypair

Set secretStores.ids.reservation_keypair to the Vaultwarden item ID. With default_slug: jupyterjsc, its fields are ssh-privatekey_jupyterjsc and ssh-publickey_jupyterjsc. Override individual suffixes with slug.reservation_keypair.ssh-privatekey and slug.reservation_keypair.ssh-publickey if needed. Store the key contents as plain text; ESO creates es-reservation-keypair with ssh-privatekey and ssh-publickey, and Kubernetes handles Secret data encoding.

The existing hub configuration mounts a Secret named reservation-keypair, not es-reservation-keypair. Creating this ExternalSecret does not change that consumer.

Unity client credentials

Set secretStores.ids.unity to the shared Vaultwarden item ID. With default_slug: jupyterjsc, it reads client_id_jupyterjsc and client_secret_jupyterjsc and creates es-unity-secret with keys client_id and client_secret. Individual suffixes can be selected using slug.unity.client_id and slug.unity.client_secret. Values are copied unchanged, and existing consumers are not changed.

Deploy jupyterhub-secrets with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has jupyterhub-secrets on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartjupyterhub-secrets is pinned at v0.1.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply