jupyterhub-metrics
by NCSA
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
| Parameter | Description | Default |
|---|---|---|
global.timescaledbEnabled | Enable/disable TimescaleDB component | true |
global.grafanaEnabled | Enable/disable Grafana component | true |
global.collectorEnabled | Enable/disable metrics collector component | true |
global.ingressEnabled | Enable/disable ingress | false |
global.debug | Enable debug mode | false |
TimescaleDB Configuration
| Parameter | Description | Default |
|---|---|---|
timescaledb.enabled | Enable TimescaleDB deployment | true |
timescaledb.database.name | Database name | jupyterhub_metrics |
timescaledb.database.user | Database username | metrics_user |
timescaledb.database.password | Database password (required) | "" |
timescaledb.database.port | Database port | 5432 |
timescaledb.external.enabled | Use external database instead of deploying TimescaleDB | false |
timescaledb.external.host | External database hostname | "" |
timescaledb.external.port | External database port | 5432 |
timescaledb.image.repository | TimescaleDB image repository | timescale/timescaledb |
timescaledb.image.tag | TimescaleDB image tag | latest-pg15 |
timescaledb.image.pullPolicy | TimescaleDB image pull policy | IfNotPresent |
timescaledb.storage.size | Storage size | 20Gi |
timescaledb.storage.storageClass | Storage class name | "" |
timescaledb.storage.accessMode | Storage access mode | ReadWriteOnce |
timescaledb.resources.requests.memory | Memory request | 512Mi |
timescaledb.resources.requests.cpu | CPU request | 250m |
timescaledb.resources.limits.memory | Memory limit | 2Gi |
timescaledb.resources.limits.cpu | CPU limit | 1000m |
timescaledb.livenessProbe.initialDelaySeconds | Liveness probe initial delay | 30 |
timescaledb.livenessProbe.periodSeconds | Liveness probe period | 10 |
timescaledb.livenessProbe.timeoutSeconds | Liveness probe timeout | 5 |
timescaledb.livenessProbe.failureThreshold | Liveness probe failure threshold | 3 |
timescaledb.readinessProbe.initialDelaySeconds | Readiness probe initial delay | 10 |
timescaledb.readinessProbe.periodSeconds | Readiness probe period | 5 |
timescaledb.readinessProbe.timeoutSeconds | Readiness probe timeout | 3 |
timescaledb.readinessProbe.failureThreshold | Readiness probe failure threshold | 3 |
timescaledb.podSecurityContext.fsGroup | Pod fsGroup | 999 |
timescaledb.podSecurityContext.runAsNonRoot | Run as non-root user | true |
timescaledb.podSecurityContext.runAsUser | User ID to run as | 999 |
timescaledb.containerSecurityContext.allowPrivilegeEscalation | Allow privilege escalation | false |
timescaledb.containerSecurityContext.capabilities.drop | Dropped capabilities | ["ALL"] |
timescaledb.containerSecurityContext.seccompProfile.type | Seccomp profile type | RuntimeDefault |
Grafana
| Parameter | Description | Default |
|---|---|---|
grafana.enabled | Enable Grafana deployment | true |
grafana.replicas | Number of Grafana replicas | 1 |
grafana.adminUser | Grafana admin username | admin |
grafana.adminPassword | Grafana admin password (required) | "" |
grafana.image.repository | Grafana image repository | grafana/grafana |
grafana.image.tag | Grafana image tag | latest |
grafana.image.pullPolicy | Grafana image pull policy | IfNotPresent |
grafana.port | Grafana service port | 3000 |
grafana.plugins | List of Grafana plugins to install | ["grafana-clock-panel"] |
grafana.persistence.enabled | Enable persistent volume for Grafana | true |
grafana.persistence.size | Persistent volume size | 5Gi |
grafana.persistence.storageClass | Storage class name | "" |
grafana.persistence.accessMode | Storage access mode | ReadWriteOnce |
grafana.resources.requests.memory | Memory request | 128Mi |
grafana.resources.requests.cpu | CPU request | 100m |
grafana.resources.limits.memory | Memory limit | 512Mi |
grafana.resources.limits.cpu | CPU limit | 500m |
grafana.livenessProbe.initialDelaySeconds | Liveness probe initial delay | 30 |
grafana.livenessProbe.periodSeconds | Liveness probe period | 10 |
grafana.livenessProbe.timeoutSeconds | Liveness probe timeout | 5 |
grafana.livenessProbe.failureThreshold | Liveness probe failure threshold | 3 |
grafana.readinessProbe.initialDelaySeconds | Readiness probe initial delay | 10 |
grafana.readinessProbe.periodSeconds | Readiness probe period | 5 |
grafana.readinessProbe.timeoutSeconds | Readiness probe timeout | 3 |
grafana.readinessProbe.failureThreshold | Readiness probe failure threshold | 3 |
grafana.podSecurityContext.fsGroup | Pod fsGroup | 472 |
grafana.podSecurityContext.runAsNonRoot | Run as non-root user | true |
grafana.podSecurityContext.runAsUser | User ID to run as | 472 |
grafana.containerSecurityContext.allowPrivilegeEscalation | Allow privilege escalation | false |
grafana.containerSecurityContext.capabilities.drop | Dropped capabilities | ["ALL"] |
grafana.containerSecurityContext.seccompProfile.type | Seccomp profile type | RuntimeDefault |
Metrics Collector
| Parameter | Description | Default |
|---|---|---|
collector.enabled | Enable metrics collector | true |
collector.interval | Collection interval in seconds | 300 |
collector.image.repository | Collector Docker image repository | ncsa/jupyterhub-metrics-collector |
collector.image.pullPolicy | Collector image pull policy | IfNotPresent |
collector.resources.requests.memory | Memory request | 128Mi |
collector.resources.requests.cpu | CPU request | 100m |
collector.resources.limits.memory | Memory limit | 512Mi |
collector.resources.limits.cpu | CPU limit | 500m |
collector.podSecurityContext.runAsNonRoot | Run as non-root user | true |
collector.podSecurityContext.runAsUser | User ID to run as | 65534 |
collector.containerSecurityContext.allowPrivilegeEscalation | Allow privilege escalation | false |
collector.containerSecurityContext.capabilities.drop | Dropped capabilities | ["ALL"] |
collector.containerSecurityContext.seccompProfile.type | Seccomp profile type | RuntimeDefault |
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
| Parameter | Description | Default |
|---|---|---|
jupyterhub.namespace | Kubernetes namespace where JupyterHub is deployed | jupyterhub |
jupyterhub.podLabelSelector | Label selector for JupyterHub singleuser pods | component=singleuser-server |
Ingress
| Parameter | Description | Default |
|---|---|---|
ingress.enabled | Enable ingress for Grafana | false |
ingress.className | Ingress class name | nginx |
ingress.host | Hostname for Grafana access | metrics.example.com |
ingress.annotations | Ingress annotations | {} |
ingress.tls.enabled | Enable TLS/HTTPS | false |
ingress.tls.secretName | TLS certificate secret name | grafana-tls |
ingress.tls.certManagerIssuer | cert-manager issuer name | "" |
RBAC
| Parameter | Description | Default |
|---|---|---|
rbac.create | Create RBAC resources | true |
rbac.serviceAccountName | Service account name | metrics-collector |
rbac.clusterRoleName | Cluster role name | jupyterhub-metrics-reader |
Secrets
| Parameter | Description | Default |
|---|---|---|
secrets.externalSecretEnabled | Use external secret | false |
secrets.externalSecretName | External secret name | "" |
secrets.externalSecretDbPasswordKey | External secret DB password key | db-password |
secrets.externalSecretGrafanaPasswordKey | External secret Grafana password key | grafana-password |
secrets.externalSecretOAuthClientIdKey | External secret OAuth client ID key | oauth-client-id |
secrets.externalSecretOAuthClientSecretKey | External secret OAuth client secret key | oauth-client-secret |
Security Context & Policies
| Parameter | Description | Default |
|---|---|---|
security.networkPolicyEnabled | Enable NetworkPolicy for traffic restriction | false |
security.podSecurityPolicyEnabled | Enable Pod Security Policy (legacy) | false |
Advanced Options
| Parameter | Description | Default |
|---|---|---|
advanced.nodeSelector | Node selector for pod placement | {} |
advanced.tolerations | Pod tolerations | [] |
advanced.affinity | Pod affinity rules | {} |
advanced.priorityClassName | Priority class name | "" |
advanced.kubeWaitTimeout | Resource creation timeout (seconds) | 300 |
Source Files Configuration
| Parameter | Description | Default |
|---|---|---|
sourceFiles.initDbSql | Path to init-db.sql (relative to project root) | init-db.sql |
sourceFiles.collectorScript | Path to collector.sh (relative to project root) | collector.sh |
sourceFiles.grafanaProvisioning | Path to Grafana provisioning directory | grafana/provisioning |
sourceFiles.grafanaDashboards | Path to Grafana dashboards directory | grafana/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
- Install External Secrets Operator (or your secret management solution)
- Create an ExternalSecret that syncs to a Kubernetes Secret with these required keys:
POSTGRES_DB- Database namePOSTGRES_USER- Database usernamePOSTGRES_PASSWORD- Database passwordGF_SECURITY_ADMIN_USER- Grafana admin usernameGF_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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartjupyterhub-metrics is pinned at v1.3.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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