jupyterhub-metrics

by NCSA

Helm chartv1.3.0App 1.3.0Verified publisher

A Helm chart for JupyterHub container metrics monitoring with TimescaleDB and Grafana

About this chart

JupyterHub Metrics

A Helm chart for Kubernetes that deploys a complete JupyterHub metrics monitoring system with TimescaleDB, Grafana, and an automated metrics collector.

Prerequisites

  • Kubernetes 1.20+
  • Helm 3.0+
  • Sufficient cluster resources:
    • Memory: At least 2Gi available
    • Storage: Persistent volume support for database

Installation

Add the Helm Repository

helm repo add ncsa https://opensource.ncsa.illinois.edu/charts/
helm repo update

Install the Chart

helm install my-release ncsa/jupyterhub-metrics \
  --namespace jupyterhub-metrics \
  --create-namespace \
  --set timescaledb.database.password="$(openssl rand -base64 32)" \
  --set grafana.adminPassword="$(openssl rand -base64 32)"

Or from local source:

helm install my-release ./chart \
  --namespace jupyterhub-metrics \
  --create-namespace \
  --set timescaledb.database.password="$(openssl rand -base64 32)" \
  --set grafana.adminPassword="$(openssl rand -base64 32)"

Install with Custom Values File

helm install my-release ./chart \
  --namespace jupyterhub-metrics \
  --create-namespace \
  -f values.yaml

Uninstalling the Chart

To uninstall/delete the my-release deployment:

helm uninstall my-release --namespace jupyterhub-metrics

To also delete the persistent volumes:

helm uninstall my-release --namespace jupyterhub-metrics
kubectl delete pvc -n jupyterhub-metrics --all

Configuration

The following table lists the configurable parameters of the JupyterHub Metrics chart and their default values.

Global Settings

ParameterDescriptionDefault
global.timescaledbEnabledEnable/disable TimescaleDB componenttrue
global.grafanaEnabledEnable/disable Grafana componenttrue
global.collectorEnabledEnable/disable metrics collector componenttrue
global.ingressEnabledEnable/disable ingressfalse
global.debugEnable debug modefalse

TimescaleDB Configuration

ParameterDescriptionDefault
timescaledb.enabledEnable TimescaleDB deploymenttrue
timescaledb.database.nameDatabase namejupyterhub_metrics
timescaledb.database.userDatabase usernamemetrics_user
timescaledb.database.passwordDatabase password (required)""
timescaledb.database.portDatabase port5432
timescaledb.external.enabledUse external database instead of deploying TimescaleDBfalse
timescaledb.external.hostExternal database hostname""
timescaledb.external.portExternal database port5432
timescaledb.image.repositoryTimescaleDB image repositorytimescale/timescaledb
timescaledb.image.tagTimescaleDB image taglatest-pg15
timescaledb.image.pullPolicyTimescaleDB image pull policyIfNotPresent
timescaledb.storage.sizeStorage size20Gi
timescaledb.storage.storageClassStorage class name""
timescaledb.storage.accessModeStorage access modeReadWriteOnce
timescaledb.resources.requests.memoryMemory request512Mi
timescaledb.resources.requests.cpuCPU request250m
timescaledb.resources.limits.memoryMemory limit2Gi
timescaledb.resources.limits.cpuCPU limit1000m
timescaledb.livenessProbe.initialDelaySecondsLiveness probe initial delay30
timescaledb.livenessProbe.periodSecondsLiveness probe period10
timescaledb.livenessProbe.timeoutSecondsLiveness probe timeout5
timescaledb.livenessProbe.failureThresholdLiveness probe failure threshold3
timescaledb.readinessProbe.initialDelaySecondsReadiness probe initial delay10
timescaledb.readinessProbe.periodSecondsReadiness probe period5
timescaledb.readinessProbe.timeoutSecondsReadiness probe timeout3
timescaledb.readinessProbe.failureThresholdReadiness probe failure threshold3
timescaledb.podSecurityContext.fsGroupPod fsGroup999
timescaledb.podSecurityContext.runAsNonRootRun as non-root usertrue
timescaledb.podSecurityContext.runAsUserUser ID to run as999
timescaledb.containerSecurityContext.allowPrivilegeEscalationAllow privilege escalationfalse
timescaledb.containerSecurityContext.capabilities.dropDropped capabilities["ALL"]
timescaledb.containerSecurityContext.seccompProfile.typeSeccomp profile typeRuntimeDefault

Grafana

ParameterDescriptionDefault
grafana.enabledEnable Grafana deploymenttrue
grafana.replicasNumber of Grafana replicas1
grafana.adminUserGrafana admin usernameadmin
grafana.adminPasswordGrafana admin password (required)""
grafana.image.repositoryGrafana image repositorygrafana/grafana
grafana.image.tagGrafana image taglatest
grafana.image.pullPolicyGrafana image pull policyIfNotPresent
grafana.portGrafana service port3000
grafana.pluginsList of Grafana plugins to install["grafana-clock-panel"]
grafana.persistence.enabledEnable persistent volume for Grafanatrue
grafana.persistence.sizePersistent volume size5Gi
grafana.persistence.storageClassStorage class name""
grafana.persistence.accessModeStorage access modeReadWriteOnce
grafana.resources.requests.memoryMemory request128Mi
grafana.resources.requests.cpuCPU request100m
grafana.resources.limits.memoryMemory limit512Mi
grafana.resources.limits.cpuCPU limit500m
grafana.livenessProbe.initialDelaySecondsLiveness probe initial delay30
grafana.livenessProbe.periodSecondsLiveness probe period10
grafana.livenessProbe.timeoutSecondsLiveness probe timeout5
grafana.livenessProbe.failureThresholdLiveness probe failure threshold3
grafana.readinessProbe.initialDelaySecondsReadiness probe initial delay10
grafana.readinessProbe.periodSecondsReadiness probe period5
grafana.readinessProbe.timeoutSecondsReadiness probe timeout3
grafana.readinessProbe.failureThresholdReadiness probe failure threshold3
grafana.podSecurityContext.fsGroupPod fsGroup472
grafana.podSecurityContext.runAsNonRootRun as non-root usertrue
grafana.podSecurityContext.runAsUserUser ID to run as472
grafana.containerSecurityContext.allowPrivilegeEscalationAllow privilege escalationfalse
grafana.containerSecurityContext.capabilities.dropDropped capabilities["ALL"]
grafana.containerSecurityContext.seccompProfile.typeSeccomp profile typeRuntimeDefault

Metrics Collector

ParameterDescriptionDefault
collector.enabledEnable metrics collectortrue
collector.intervalCollection interval in seconds300
collector.image.repositoryCollector Docker image repositoryncsa/jupyterhub-metrics-collector
collector.image.pullPolicyCollector image pull policyIfNotPresent
collector.resources.requests.memoryMemory request128Mi
collector.resources.requests.cpuCPU request100m
collector.resources.limits.memoryMemory limit512Mi
collector.resources.limits.cpuCPU limit500m
collector.podSecurityContext.runAsNonRootRun as non-root usertrue
collector.podSecurityContext.runAsUserUser ID to run as65534
collector.containerSecurityContext.allowPrivilegeEscalationAllow privilege escalationfalse
collector.containerSecurityContext.capabilities.dropDropped capabilities["ALL"]
collector.containerSecurityContext.seccompProfile.typeSeccomp profile typeRuntimeDefault

Note: The collector image version is automatically set to match the chart version (from Chart.yaml). The collector image must be built and pushed before deploying the chart.

JupyterHub Target

ParameterDescriptionDefault
jupyterhub.namespaceKubernetes namespace where JupyterHub is deployedjupyterhub
jupyterhub.podLabelSelectorLabel selector for JupyterHub singleuser podscomponent=singleuser-server

Ingress

ParameterDescriptionDefault
ingress.enabledEnable ingress for Grafanafalse
ingress.classNameIngress class namenginx
ingress.hostHostname for Grafana accessmetrics.example.com
ingress.annotationsIngress annotations{}
ingress.tls.enabledEnable TLS/HTTPSfalse
ingress.tls.secretNameTLS certificate secret namegrafana-tls
ingress.tls.certManagerIssuercert-manager issuer name""

RBAC

ParameterDescriptionDefault
rbac.createCreate RBAC resourcestrue
rbac.serviceAccountNameService account namemetrics-collector
rbac.clusterRoleNameCluster role namejupyterhub-metrics-reader

Secrets

ParameterDescriptionDefault
secrets.externalSecretEnabledUse external secretfalse
secrets.externalSecretNameExternal secret name""
secrets.externalSecretDbPasswordKeyExternal secret DB password keydb-password
secrets.externalSecretGrafanaPasswordKeyExternal secret Grafana password keygrafana-password
secrets.externalSecretOAuthClientIdKeyExternal secret OAuth client ID keyoauth-client-id
secrets.externalSecretOAuthClientSecretKeyExternal secret OAuth client secret keyoauth-client-secret

Security Context & Policies

ParameterDescriptionDefault
security.networkPolicyEnabledEnable NetworkPolicy for traffic restrictionfalse
security.podSecurityPolicyEnabledEnable Pod Security Policy (legacy)false

Advanced Options

ParameterDescriptionDefault
advanced.nodeSelectorNode selector for pod placement{}
advanced.tolerationsPod tolerations[]
advanced.affinityPod affinity rules{}
advanced.priorityClassNamePriority class name""
advanced.kubeWaitTimeoutResource creation timeout (seconds)300

Source Files Configuration

ParameterDescriptionDefault
sourceFiles.initDbSqlPath to init-db.sql (relative to project root)init-db.sql
sourceFiles.collectorScriptPath to collector.sh (relative to project root)collector.sh
sourceFiles.grafanaProvisioningPath to Grafana provisioning directorygrafana/provisioning
sourceFiles.grafanaDashboardsPath to Grafana dashboards directorygrafana/dashboards

Note: These paths are used by the update-chart.sh script to sync source files into the Helm chart templates. They are not used at runtime.

Examples

Basic Installation with Required Parameters

helm install my-release ./chart \
  --namespace jupyterhub-metrics \
  --create-namespace \
  --set timescaledb.database.password="my-secure-db-password" \
  --set grafana.adminPassword="my-secure-grafana-password"

Installation with External Database

helm install my-release ./chart \
  --namespace jupyterhub-metrics \
  --create-namespace \
  --set timescaledb.enabled=false \
  --set timescaledb.external.enabled=true \
  --set timescaledb.external.host="postgresql.example.com" \
  --set timescaledb.external.port="5432" \
  --set timescaledb.database.password="my-secure-db-password" \
  --set grafana.adminPassword="my-secure-grafana-password"

Installation with Ingress and TLS

helm install my-release ./chart \
  --namespace jupyterhub-metrics \
  --create-namespace \
  --set timescaledb.database.password="my-secure-db-password" \
  --set grafana.adminPassword="my-secure-grafana-password" \
  --set ingress.enabled=true \
  --set ingress.host="metrics.example.com" \
  --set ingress.tls.enabled=true \
  --set ingress.tls.certManagerIssuer="letsencrypt-prod"

Installation with Custom Grafana Storage

helm install my-release ./chart \
  --namespace jupyterhub-metrics \
  --create-namespace \
  --set timescaledb.database.password="my-secure-db-password" \
  --set grafana.adminPassword="my-secure-grafana-password" \
  --set grafana.persistence.size="10Gi"

Installation with External Secrets

When using an external secrets management solution (e.g., External Secrets Operator with AWS Secrets Manager, HashiCorp Vault, etc.), you can reference an existing Kubernetes Secret instead of having Helm create one.

Important: When secrets.externalSecretEnabled: true, the chart will NOT create a Secret resource. You must ensure your external secret exists before installation.

Prerequisites

  1. Install External Secrets Operator (or your secret management solution)
  2. Create an ExternalSecret that syncs to a Kubernetes Secret with these required keys:
    • POSTGRES_DB - Database name
    • POSTGRES_USER - Database username
    • POSTGRES_PASSWORD - Database password
    • GF_SECURITY_ADMIN_USER - Grafana admin username
    • GF_SECURITY_ADMIN_PASSWORD - Grafana admin password

Example: Using External Secrets Operator with AWS Secrets Manager

# Step 1: Create ExternalSecret resource
cat <<EOF | kubectl apply -f -
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret

Deploy jupyterhub-metrics with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has jupyterhub-metrics 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-metrics is pinned at v1.3.0 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