前置条件
在开始之前,确保你已经具备以下条件:
| 组件 | 版本要求 | 说明 |
|---|---|---|
Kubernetes | >= 1.23 | 需要有可用的K8S集群,支持动态存储卷 |
Helm | >= 3.5 | Kubernetes包管理工具 |
kubectl | 与集群版本匹配 | 已配置并可以访问你的K8S集群 |
| 集群资源 | 至少2个worker节点 | 每个节点建议4GB+内存,2C+CPU |
存储类(StorageClass) | 支持动态供给 | 用于用户数据持久化存储 |
| 镜像仓库 | 可选 | 如需使用自定义镜像,需要可访问的镜像仓库 |
部署JupyterHub
添加JupyterHub Helm仓库
首先,将JupyterHub的Helm Chart仓库添加到本地:
helm repo add jupyterhub https://hub.jupyter.org/helm-chart/
helm repo update
安装JupyterHub
使用Helm拉取JupyterHub安装包:
helm pull jupyterhub/jupyterhub --version=4.3.2 --untar
使用以下指令安装JupyterHub:
helm install jupyterhub ./jupyterhub -n jupyterhub-system --create-namespace
验证部署
查看Pod状态:
kubectl get pod --namespace jupyterhub-system
等待所有Pod进入Running状态:
NAME READY STATUS RESTARTS AGE
continuous-image-puller-7f49d 1/1 Running 0 1m
continuous-image-puller-7j4jg 1/1 Running 0 1m
continuous-image-puller-hrj2c 1/1 Running 0 1m
continuous-image-puller-qkgb6 1/1 Running 0 1m
hub-5c5d9f7678-vkjpc 1/1 Running 0 1m
proxy-6496d4dff4-b9fts 1/1 Running 0 1m
user-scheduler-6fcfff9557-k55c6 1/1 Running 0 1m
user-scheduler-6fcfff9557-pgpnx 1/1 Running 0 1m
访问JupyterHub
通过kubectl port-forward获取访问地址:
kubectl port-forward --namespace=jupyterhub-system service/proxy-public 8080:http
在浏览器中访问 http://localhost:8080 地址即可打开JupyterHub登录页面。
卸载JupyterHub
helm uninstall jupyterhub -n jupyterhub-system