k8s和helm安裝jupyterhub


參考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

# 默認打開jupyterlab
singleuser:
  defaultUrl: "/lab"
hub:
  extraConfig:
    myConfig.py: |
      c.Spawner.cmd = ['jupyter-labhub']
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,所以用戶名密碼可以隨便輸入。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM