參考jupyterhub官網給的安裝教程Zero to JupyterHub for Kubernetes
下載docker
從docker官網下載docker desktop的安裝包,並安裝。
安裝Kubernetes
在docker dashboard上點擊設置按鈕,選擇Kubernetes,勾選Enable Kubernetes,等待下載完成之後Apply & Restart重啟。
安裝helm
mac下運行brew install helm即可。
有可能需要修改國內鏡像源,如切換清華源:
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
$ brew update
安裝JupyterHub
# 添加chart
$ helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/
$ helm repo update
# 生成一個隨機字符串作為JupyterHub的安全Token
$ openssl rand -hex 32
# 新建一個config.yaml文件,如下配置:
$ vim config.yaml
proxy:
secretToken: "0d7db40535787b779bceb04806235978c5e1c28cbcb240cda9adf8820af8bb40" # 這裏寫剛剛生成的Token
# 創建並編輯helm install脚本,如下內容:
$ vim helm-install-jupyterhub.sh
RELEASE=jhub
NAMESPACE=jhub
helm upgrade --cleanup-on-fail \
--install $RELEASE jupyterhub/jupyterhub \
--namespace $NAMESPACE \
--create-namespace \
--version=1.1.3 \
--values config.yaml \
--timeout 600s
# 運行安裝jupyterhub
$ chmod +x helm-install-jupyterhub.sh
$ ./helm-install-jupyterhub.sh
按理來說,但現在就算安裝完成了,但是在最後一步安裝的時候由於網絡牆的原因會出現拉取鏡像失敗。
kubectl get pod -n jhub。查看pod命名空間下的所有容器,會發現有容器的STATUS為ErrImagePull。
kubectl describe pod hook-image-puller-8wrxh -n jhub。這個時候我們就要去看這個容器在拉取哪個鏡像的時候出錯了。
發現是k8s.gcr.io/pause:3.5,打開科學的上網方法,docker pull k8s.gcr.io/pause:3.5。
重新運行安裝脚本./helm-install-jupyterhub.sh。
kubectl get pod -n jhub。查看pod命名空間下的所有容器,會發現有容器的STATUS為ImagePullBackoff。
kubectl describe pod user-scheduler-78d486d6fb-ksdzm -n jhub。同樣去看這個容器在拉取哪個鏡像的時候出錯了。
發現是k8s.gcr.io/kube-scheduler:v1.19.13,打開科學的上網方法,docker pull k8s.gcr.io/kube-scheduler:v1.19.13。
然後再次運行kubectl get pod -n jhub,發現容器都運行正常。
kubectl get svc -n jhub,查看jhub命名空間下的所有服務,
kubectl edit service proxy-public -n jhub,修改proxy-public的type為NodePort。
瀏覽器打開http://localhost:31832
由於是用的dummyAuth,所以用戶名密碼可以隨便輸入。