當咱們有了 Kubernetes cluster 和 helm 安裝好後,就能夠開始安裝 JupyterHub了。html
如下爲官方文檔描述的方法,目前按照下面方法自建的config.yaml安裝時會出錯,可能與helm chart編寫、Helm版本等都有關係,還須要完善。建議參照上面的方法來安裝。git
準備一個配置文件 (config file). 使用 YAML 文件格式來指定JupyterHub的配置參數。github
保存該配置文件到安全的地方,之後還會用來更新JupyterHub的設置。瀏覽器
執行下面的步驟,咱們使用 nano 編輯器。安全
建立文件 config.yaml
,執行 nano config.yaml
而後編輯。app
建立隨機hex string做爲安全令牌,運行:編輯器
openssl rand -hex 32
複製下來。ide
插入文件 config.yaml
。當編輯YAML 文件時,使用空格縮進,不要用tab鍵。替換 RANDOM_STRING
爲上面 openssl rand -hex 32
生成的字符串。工具
proxy: secretToken: "<OUTPUT-OF-`openssl rand -hex 32`>"
Azure AKS有效,若是使用 Azure AKS, 必須關閉RBAC,設置以下的配置:
spa
rbac: enabled: false
查看 RBAC documentation 得到更多細節。
ctl+x保存 config.yaml
文件。
添加 JupyterHub helm repository 到本地 repo中,以便從中直接安裝JupyterHub。這使使用 JupyterHub chart 更爲方便,而沒必要輸入長長的URL。
helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/ helm repo update
輸出以下:
Hang tight while we grab the latest from your chart repositories... ...Skip local chart repository ...Successfully got an update from the "stable" chart repository ...Successfully got an update from the "jupyterhub" chart repository Update Complete. ⎈ Happy Helming!⎈
從包含 config.yaml
文件的目錄運行以下命令,來安裝JupyterHub:
helm install jupyterhub/jupyterhub \ --version=v0.6 \ --name=<YOUR-RELEASE-NAME> \ --namespace=<YOUR-NAMESPACE> \ -f config.yaml
建議 --name
和 --namespace
設爲同樣,以減小混淆,雖然不是必須。
注意:
--name
helm deployment的名稱,可以使用helm list查看。--namespace
是 Kubernetes (among other things) 的命名空間,安裝時會自動建立。後續的 kubectl
執行操做須要指明在特定的命名空間下操做,如 -n mynamespace。release named <YOUR-RELEASE-NAME> already exists
error,經過運行 helm delete --purge <YOUR-RELEASE-NAME> 來刪除已有的安裝。若是換是不行,使用
kubectl delete <YOUR-NAMESPACE>
來刪除,再從新安裝。helm delete --purge <YOUR-RELEASE-NAME>
。Error: timed out waiting for the condition
error, 添加 --timeout=SOME-LARGE-NUMBER
到 helm install
命令。--version
對應於helm chart的版本,而不是JupyterHub版本。每個JupyterHub helm chart 對應於JupyterHub的版本,好比v0.5的 helm chart運行JupyterHub v0.8。查看安裝後產生的pod:
kubectl --namespace=<YOUR-NAMESPACE> get pod
等到 hub 和 proxy pod 開始運行。
查到JupyterHub的服務 IP,以下:
kubectl --namespace=<YOUR-NAMESPACE> get svc
這裏的 proxy-public
service 的external IP一下子就能夠訪問了。
注意:
若是proxy-public
輸出過長,可使用:
kubectl --namespace=<YOUR-NAMESPACE> describe svc proxy-public --output=wide
到瀏覽器,輸入proxy-public
service 的 external IP。在登陸頁面輸入任何username 和 password 的組合均可以進入jupyterhub頁面。
你還能夠不少種方式 extend it ,可使用預先構建的用戶容器鏡像,或者本身構建一個,使用不一樣的權限和安裝不一樣的軟件,裏面的軟件包使用conda管理。後續再介紹詳細的方法。