My Setup / Overview #
I’m using the following setup:
- Debian 13
- NVIDIA 5070 Ti
- k3s version v1.36.6+k3s1
- Cilium version 1.20.4
- kgateway Helm chart version v2.5.1
Jupyter Helm Overview #
# Add JupyterHub Helm repository
helm repo add jupyterhub https://hub.jupyter.org/helm-chart/ &&
helm repo update
# List available versions of the chart
helm search repo jupyterhub/jupyterhub --versions
# Shell output:
NAME CHART VERSION APP VERSION DESCRIPTION
jupyterhub/jupyterhub 4.4.5 5.5.5 Multi-user Jupyter installation
jupyterhub/jupyterhub 4.4.4 5.5.4 Multi-user Jupyter installation
...
# Save Helm chart values
helm show values jupyterhub/jupyterhub --version 4.4.5 > jupyterhub-values-4.4.5.yml
Ansible Setup #
Playbook #
- k8s_jupyterhub.yml
---
- name: JupyterHub Helm installation
hosts: localhost
connection: local
gather_facts: false
become: false
environment:
KUBECONFIG: "{{ lookup('env', 'HOME') }}/.kube/k3spc1.yaml"
vars:
# Helm Configuration
helm_repository: "https://hub.jupyter.org/helm-chart/"
helm_chart: "jupyterhub/jupyterhub"
helm_chart_version: "4.4.5"
helm_release_name: "jupyterhub"
kubernetes_namespace: "jupyterhub"
# Storage Configuration
kubernetes_storage_class: "local-path"
kubernetes_pvc_size: "10Gi"
# Routing Configuration
jupyterhub_hostname: "jupyterhub.jklug.work"
gateway_name: "kgateway-metallb"
gateway_namespace: "kgateway-infra"
gateway_section: "https"
# JupyterHub Configuration
notebook_image: "quay.io/jupyter/pytorch-notebook:cuda12-latest"
roles:
- k8s_jupyterhub
# Run playbook:
ansible-playbook playbooks/k8s_jupyterhub.yml
Role #
tasks/main.yml
- name: Create namespace
kubernetes.core.k8s:
api_version: v1
kind: Namespace
name: "{{ kubernetes_namespace }}"
state: present
- name: Add Helm repository
kubernetes.core.helm_repository:
repo_name: jupyterhub
repo_url: "{{ helm_repository }}"
repo_state: present
- name: Install Helm Chart
kubernetes.core.helm:
name: "{{ helm_release_name }}"
chart_ref: "{{ helm_chart }}"
chart_version: "{{ helm_chart_version }}"
release_namespace: "{{ kubernetes_namespace }}"
create_namespace: false
wait: false # Ansible waits till all resources are ready
wait_timeout: 3m0s
atomic: false # Auto-rollback on failure
values: "{{ lookup('template', 'helm-values.yml.j2') | from_yaml }}"
- name: Allow JupyterHub hub to reach the Kubernetes API (Cilium policy)
kubernetes.core.k8s:
state: present
definition:
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: hub-to-kube-apiserver
namespace: "{{ kubernetes_namespace }}"
spec:
endpointSelector:
matchLabels:
component: hub
egress:
- toEntities:
- kube-apiserver
- name: Enable WebSocket upgrades on the gateway (Gateway policy)
kubernetes.core.k8s:
state: present
definition:
apiVersion: gateway.kgateway.dev/v1alpha1
kind: ListenerPolicy
metadata:
name: http2-websocket
namespace: "{{ gateway_namespace }}"
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: "{{ gateway_name }}"
default:
httpSettings:
upgradeConfig:
enabledUpgrades:
- websocket
Templates #
proxy:
service:
type: ClusterIP
singleuser:
storage:
type: dynamic
capacity: "{{ kubernetes_pvc_size }}"
dynamic:
storageClass: "{{ kubernetes_storage_class }}"
profileList:
- display_name: "CPU (default)"
default: true
- display_name: "GPU (PyTorch + CUDA)"
description: "Uses the NVIDIA GPU on the GPU worker node"
kubespawner_override:
image: "{{ notebook_image }}"
extra_resource_limits:
nvidia.com/gpu: "1"
extra_pod_config:
runtimeClassName: nvidia
httpRoute:
enabled: true
hostnames:
- "{{ jupyterhub_hostname }}"
gateway:
name: "{{ gateway_name }}"
namespace: "{{ gateway_namespace }}"
sectionName: "{{ gateway_section }}"
Webinterface #
Webinterface: https://jupyterhub.jklug.work
- With the dummy authenticator any user/pw can be used
- Login with a random username and pw like
juergen
Kubernetes Resources #
After Helm Installation #
# List default resources
kubectl -n jupyterhub get all
# Shell output:
NAME READY STATUS RESTARTS AGE
pod/continuous-image-puller-2l89t 1/1 Running 0 35s
pod/hub-574d769f56-qzhvm 1/1 Running 0 35s
pod/proxy-744fb5d8b4-24kd6 1/1 Running 0 35s
pod/user-scheduler-7d98d84496-5gczw 1/1 Running 0 35s
pod/user-scheduler-7d98d84496-7q9ts 1/1 Running 0 35s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/hub ClusterIP 10.201.238.144 <none> 8081/TCP 35s
service/proxy-api ClusterIP 10.201.119.179 <none> 8001/TCP 35s
service/proxy-public ClusterIP 10.201.73.25 <none> 80/TCP 35s
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/continuous-image-puller 1 1 1 1 1 <none> 35s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/hub 1/1 1 1 35s
deployment.apps/proxy 1/1 1 1 35s
deployment.apps/user-scheduler 2/2 2 2 35s
NAME DESIRED CURRENT READY AGE
replicaset.apps/hub-574d769f56 1 1 1 35s
replicaset.apps/proxy-744fb5d8b4 1 1 1 35s
replicaset.apps/user-scheduler-7d98d84496 2 2 2 35s
NAME READY AGE
statefulset.apps/user-placeholder 0/0 35s
# List HTTPRoute
kubectl -n jupyterhub get httproute
# Shell output:
NAME HOSTNAMES AGE
jupyterhub ["jupyterhub.jklug.work"] 41s
# List PVC
kubectl -n jupyterhub get pvc
# Shell output:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
hub-db-dir Bound pvc-320191fa-5704-46b6-a2fe-43decce5c1ef 1Gi RWO local-path <unset> 52s
Verify Hub pod Label for NetworkPolicy #
# Verify label
kubectl -n jupyterhub get pod -l component=hub --show-labels
# Shell output:
NAME READY STATUS RESTARTS AGE LABELS
hub-574d769f56-qzhvm 1/1 Running 0 70s app.kubernetes.io/component=hub,app.kubernetes.io/instance=jupyterhub,app.kubernetes.io/name=jupyterhub,app=jupyterhub,component=hub,hub.jupyter.org/network-access-proxy-api=true,hub.jupyter.org/network-access-proxy-http=true,hub.jupyter.org/network-access-singleuser=true,pod-template-hash=574d769f56,release=jupyterhub
After User Login #
# List PVC
kubectl -n jupyterhub get pvc
# Shell output:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
claim-juergen Bound pvc-928e8980-192e-42d6-ac53-a0ac1331b76c 10Gi RWO local-path <unset> 77s
hub-db-dir Bound pvc-13a2e540-496f-4037-9dca-85a906676c9a 1Gi RWO local-path <unset> 7m34s
# List default resources
kubectl -n jupyterhub get pod
# Shell output:
NAME READY STATUS RESTARTS AGE
continuous-image-puller-2l89t 1/1 Running 0 7m37s
hub-574d769f56-qzhvm 1/1 Running 0 7m37s
jupyter-juergen 1/1 Running 0 80s # Check
proxy-744fb5d8b4-24kd6 1/1 Running 0 7m37s
user-scheduler-7d98d84496-5gczw 1/1 Running 0 7m37s
user-scheduler-7d98d84496-7q9ts 1/1 Running 0 7m37s
Run Notebook #
# Verify CUDA and GPU
import torch
print(torch.cuda.is_available())
print(torch.cuda.get_device_name(0))
# Shell output:
True
NVIDIA GeForce RTX 5070 Ti
# Run NVIDIA-SMI
!nvidia-smi
# Shell output:
Sun Nov 22 14:07:53 2026
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.112.07 Driver Version: 595.112.07 CUDA Version: 13.2 |
+-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 5070 Ti On | 00000000:01:00.0 Off | N/A |
| 0% 34C P8 12W / 300W | 4MiB / 16303MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+