经过Helm在Kubernetes集群上安装IPFS

经过Helm在Kubernetes集群上安装IPFS

Helm (https://helm.sh/) 是用于Kubernetes的应用包管理程序,能够按照定义来安装、启动、中止、删除由多个Docker和Pod组合的服务应用,并且具备回滚等功能。node

  • Helm的后台服务为Tiller,包描述文件称为Chart,是yaml格式,与Docker Compose有相似之处,但可选参数更多。
  • Helm的Chart能够保存在本地文件、本地Repo、Monocular或者Github等各类文件服务系统之中。
  • Helm安装方法,参见:http://www.javashuo.com/article/p-blstqlzm-dh.html

IPFS (http://ipfs.io/)能够经过Helm在Kubernetes集群上快速部署和方便地管理。nginx

IPFS其它运行方式还有:git

这里描述基于Helm的IPFS安装步骤。github

  • 此处的方法在Docker for Mac Edge 18.02 mac53上运行经过。

一、复制Helm Charts库

git clone https://github.com/openthings/zhelm-charts.git

由于咱们要进行一些修改,将stable/ipfs复制到本身的目录,如:zolo/ipfs。上面的库中已包含这个目录。由于Kubernetes官方Chart的ipfs版本较低,咱们将其改成最新的0.4.13版本(注意values.yaml和Chart.yaml两个文件里的修改部分)。web

二、安装IPFS Chart

进入目录 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
  • 注意,除了上面以外,咱们还须要映射5001端口以便于本地管理,所以,最后一行改成:
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服务。

五、删除ipfs-node服务

若是再也不须要了,能够一行命令删除之。

#删除运行的服务
helm delete ipfs-node

#完全删除Helm部署,从新安装
helm del --purge ipfs-node

更多参考

相关文章
相关标签/搜索