Helm (https://helm.sh/) 是用於Kubernetes的應用包管理程序,能夠按照定義來安裝、啓動、中止、刪除由多個Docker和Pod組合的服務應用,並且具備回滾等功能。node
IPFS (http://ipfs.io/)能夠經過Helm在Kubernetes集羣上快速部署和方便地管理。nginx
IPFS其它運行方式還有:git
這裏描述基於Helm的IPFS安裝步驟。github
git clone https://github.com/openthings/zhelm-charts.git
由於咱們要進行一些修改,將stable/ipfs複製到本身的目錄,如:zolo/ipfs。上面的庫中已包含這個目錄。由於Kubernetes官方Chart的ipfs版本較低,咱們將其改成最新的0.4.13版本(注意values.yaml和Chart.yaml兩個文件裏的修改部分)。web
進入目錄 zolo/ipfs,運行:mongodb
helm install --name ipfs-node .
輸出以下:json
NAME: ipfs-node LAST DEPLOYED: Tue Feb 13 21:24:04 2018 NAMESPACE: default STATUS: DEPLOYED RESOURCES: ==> v1/Service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ipfs-node-ipfs ClusterIP 10.98.146.104 <none> 5001/TCP,8080/TCP 0s ==> v1beta1/StatefulSet NAME DESIRED CURRENT AGE ipfs-node-ipfs 1 1 0s NOTES: You have successfully installed IPFS in your kubernetes cluster! You can access the IPFS API from inside your cluster by connecting to port 5001 on ipfs-node-ipfs.default You can also connect to port 8080 on the same hostname for talking to the IPFS Gateway. If you want to connect to it from your local computer, you can find a URL to connect with the following (for the gateway service): export POD_NAME=$(kubectl get pods --namespace default -l "app=ipfs,release=ipfs-node" -o jsonpath="{.items[0].metadata.name}") echo "Use the API Gateway by accessing http://localhost:8080/ipfs/<IPFS-HASH>" kubectl --namespace default port-forward $POD_NAME 8080:8080
kubectl get pod
輸出以下:api
NAME READY STATUS RESTARTS AGE ipfs-node-ipfs-0 1/1 Running 0 1m peddling-kitten-mongodb-55d9b47bb9-gb7tp 1/1 Running 0 2d peddling-kitten-monocular-api-6744c4cc66-gcsrs 1/1 Running 3 2d peddling-kitten-monocular-api-6744c4cc66-gfz5t 1/1 Running 1 2d peddling-kitten-monocular-prerender-5fcbd99b78-h2t6v 1/1 Running 0 2d peddling-kitten-monocular-ui-7977d5c949-c47sj 1/1 Running 0 2d peddling-kitten-monocular-ui-7977d5c949-kchp4 1/1 Running 0 2d wondering-yak-nginx-ingress-controller-7cd79f85cd-88z2b 1/1 Running 0 2d wondering-yak-nginx-ingress-default-backend-55755b66b4-hwd4z 1/1 Running 0 2d
能夠看到ipfs-node的Pod已經運行起來了(若是第一次運行,須要下載ipfs的Docker鏡像,須要耐心等待STATUS變爲Running,再進行後續操做)。瀏覽器
這裏使用Kubernetes的port-forward方法映射服務端口到主機端口,但每次需喲啊運行一個服務。更多的方法參見:app
如今按照提示,獲取信息,映射服務端口:
export POD_NAME=$(kubectl get pods --namespace default -l "app=ipfs,release=ipfs-node" -o jsonpath="{.items[0].metadata.name}") echo "Use the API Gateway by accessing http://localhost:8080/ipfs/<IPFS-HASH>" kubectl --namespace default port-forward $POD_NAME 8080:8080
kubectl --namespace default port-forward $POD_NAME 8080:8080 5001:5001
保持這個命令一直運行,打開瀏覽器,輸入:http://127.0.0.1:5001/webui,能夠看到IPFS的本地管理界面。能夠在裏面上傳文件,而後使用:http://127.0.0.1:8080/ipfs/<IPFS-HASH>的方式訪問。鼠標右鍵單擊Files裏所上傳的文件也能夠得到該文件資源的HashCode值。
使用其它的Kubenetes管理工具(如Kubernetes Dashboard)也能夠看到部署的pod服務。
若是再也不須要了,能夠一行命令刪除之。
#刪除運行的服務 helm delete ipfs-node #完全刪除Helm部署,從新安裝 helm del --purge ipfs-node