前提条件:准备好的k8s环境和helm环境
准备配置文件
生成随机数
openssl rand -hex 32
# 8fc2826e9ce6930ec26c9fd541c0620b448a947357edbdf9647516af16bbc798
配置config.yaml如下,token是上一步生成
proxy:
secretToken: "8fc2826e9ce6930ec26c9fd541c0620b448a947357edbdf9647516af16bbc798"
安装JupyterHub
- 安装helm部署仓库,注意需要全局代理
helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/
helm repo update
安装完成后会有如下显示
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "sqlfiddle" chart repository
...Successfully got an update from the "jupyterhub" chart repository
...Successfully got an update from the "emberstack" chart repository
Update Complete. ⎈ Happy Helming!⎈
- 接下来使用helm安装JupyterHub,并使用我们刚刚配置的config.yaml
创建helm-install-hupyterhub.sh文件,并复制如下进去:
# Suggested values: advanced users of Kubernetes and Helm should feel
# free to use different values.
RELEASE=jhub
NAMESPACE=jhub
helm upgrade --install $RELEASE jupyterhub/jupyterhub \
--namespace $NAMESPACE \
--version=0.9.0 \
--values config.yaml
创建k8s的jhub namespace
kubectl create ns jhub
注意:遇到问题:Release “jupyterhub” does not exist. Installing it now.,
# 在master节点执行
kubectl get pod --namespace jhub
# 查看pod节点异常情况
kubectl describe po hook-image-puller-h9mwm --namespace jhub
错误原因是 镜像无法拉取
打开代理环境,获取镜像
docker pull gcr.io/google_containers/kube-scheduler-amd64:v1.13.12
docker pull gcr.io/google_containers/pause:3.1
当部署成功时
kubectl -n jhub get po
# continuous-image-puller-x5fwx 1/1 Running 0 4m45s
# hub-75d769476f-tdz8l 1/1 Running 0 4m45s
# proxy-d769dd5db-c7pqf 1/1 Running 0 4m45s
# user-scheduler-64b57d78d5-8dv7s 1/1 Running 0 4m45s
# user-scheduler-64b57d78d5-zk2cb 1/1 Running 0 4m45s
kubectl get service --namespace jhub
# hub ClusterIP 10.99.233.188 <none> 8081/TCP 6m12s
# proxy-api ClusterIP 10.100.28.140 <none> 8001/TCP 6m12s
# proxy-public LoadBalancer 10.104.115.249 localhost 443:32556/TCP,80:30533/TCP 6m12s
修改proxy-public svc 将 type: LoadBalancer 改成 type: NodePort
kubectl edit service proxy-public -n jhub
查看service
kubectl get service --namespace jhub
# hub ClusterIP 10.99.233.188 <none> 8081/TCP 16m
# proxy-api ClusterIP 10.100.28.140 <none> 8001/TCP 16m
# proxy-public NodePort 10.104.115.249 <none> 443:32556/TCP,80:30533/TCP 16m
此时我们在浏览器中通过 80 映射的端口去访问jupyterhub
jupyterhub的默认用户:bi:bi
测试运行