Deploy IPFS cluster peer
IPFS Cluster provides data orchestration across a swarm of IPFS daemons by allocating, replicating and tracking a global pinset distributed among multiple peers. Source
Prerequisites
Before we start, you need to:
Step 1 - Deploy IPFS Peer
Deploy an ipfs peer Peer because it's required by ClusterPeer. Check our Deploy IPFS Peer tutorial.
Step 2 - Generate Cluster Secret
Create a cluster secret which secures access to the cluster:
CLUSTER_SECRET=$(openssl rand -hex 32)
kubectl create secret generic cluster-secret --from-literal=secret=$CLUSTER_SECRETCluster secret must be 32-byte hex-encoded (64 characters) without the leading 0x. It must be hold in data field called secret in the Kubernetes secret.
Step 3 - Generate ID and Private Key
Create cluster peer ID and private key using ipfs-key
ipfs-key -type ed25519 | base64It will return an output similar to the following:
Generating a 2048 bit ed25519 key...
Success!
ID for generated key: 12D3KooWBcEtY8GH4mNkri9kM3haeWhEXtQV7mi81ErWrqLYGuiq
CAESQOH/DvUJmeJ9z6m3wAStpkrlBwJQxIyNSK0YGf0EI5ZRGpwsWxl4wmgReqmHl8LQjTC2iPM0QbYAjeY3Z63AFnI=Step 4 - Deploy Private Key Secret
create Kubernetes secret from the generated private key in step(3) above.
Deploying First Cluster Peer
Now we're ready to deploy the cluster peer and connect it to the peer we've deployed in step(1)
Let's deploy cluster peer manifest file:
Kotal operator will notice your cluster-peer and will create all the necessary pods, persistent volumes, services, configmaps, and secrets.
You can fetch the deployed IPFS ClusterPeer using:
It will return an output similar to the following:
Fetch Cluster Peer Logs
Get the pods created for our cluster peer:
It will return an output similar to the following:
Check the logs of the running cluster peer:
It will return an output similar to the following:
As you can see from the logs that our cluster peer is up and running as indicated by the healthy logs IPFS Cluster is READY.
Update Cluster Pinset
Let's add some content to the pinset by executing commands inside cluster peer container:
Let's fetch the pinset of the ipfs peer by executing commands inside peer -created in step(1)- container:
As you can see, content pinned by the cluster peer, has been added to the pinset of the ipfs peer and available in its local storage.
Deploying Second Cluster Peer
The only prerequisite to the second cluster peer is to:
Step 1 - Deploy IPFS Peer
Deploy an ipfs peer Peer, and name it peer-sample-two. Check our Deploy IPFS Peer tutorial.
We will reuse cluster secret that was generated in step(2) during deploying first cluster peer above.
Deploying this cluster manifest will deploy a cluster peer that connects to the first cluster peer and will connect to its own ipfs peer peer-sample-two instance.
You can fetch the deployed cluster peers by:
It will return an output similar to the following:
Fetch Second Cluster Peer Logs
Get the pods created by our cluster peer:
It will return an output similar to the following:
Check the logs of cluster peer two:
It will return an output similar to the following:
As you can see cluster peer two is up and running as indicated by the healthy logs and IPFS Cluster is READY.
Cluster peer two has joined the first cluster peer as indicated by the highlighted log line joined 12D...uiq's cluster
Finally, delete all peers and cluster peers:
Kubernetes garbage collector will delete all the resources that has been created by Kotal IPFS Peer and ClusterPeer controllers.
Last updated
Was this helpful?