Private IPFS Network Setup
Set up private IPFS network
Note that Bacalhauv1.4.0
supports IPFS v0.27
and below.
Starting from v.1.5.0
Bacalhau supports latest IPFS versions.
Consider this when selecting versions of Bacalhau and IPFS when setting up your own private network.
Introduction
Support for the embedded IPFS node was discontinued in v1.4.0
to streamline communication and reduce overhead. Therefore, now in order to use a private IPFS network, it is necessary to create it yourself and then connect to it with nodes. This manual describes how to:
Install and configure IPFS
Create Private IPFS network
Configure your Bacalhau network to use the private IPFS network
Pin your data to private IPFS network
TL;DR
Install Go on all nodes
Install IPFS
Initialize Private IPFS network
Connect all nodes to the same private network
Connect Bacalhau network to use private IPFS network
Download and Install
In this manual Kubo (the earliest and most widely used implementation of IPFS) will be used, so first of all, Go should be installed.
See the Go Downloads page for latest Go version.
Remove any previous Go installation by deleting the
/usr/local/go
folder (if it exists), then extract the archive you downloaded into/usr/local
, creating a fresh Go tree in/usr/local/go
:
Add
/usr/local/go/bin
to thePATH
environment variable. You can do this by adding the following line to your$HOME/.profile
or/etc/profile
(for a system-wide installation):
Changes made to a profile file may not apply until the next time you log into the system. To apply the changes immediately, just run the shell commands directly or execute them from the profile using a command such as source $HOME/.profile
.
Verify that Go is installed correctly by checking its version:
The next step is to download and install Kubo. Select and download the appropriate version for your system. It is recommended to use the latest stable version.
Verify that IPFS
is installed correctly by checking its version:
Configure Bootstrap IPFS Node
A bootstrap node is used by client nodes to connect to the private IPFS network. The bootstrap connects clients to other nodes available on the network.
Execute the ipfs init
command to initialize an IPFS node:
The next step is to generate the swarm key - a cryptographic key that is used to control access to an IPFS network, and export the key into a swarm.key
file, located in the ~/ipfs
folder.
Now the default entries of bootstrap nodes should be removed. Execute the command on all nodes:
Check that bootstrap config does not contain default values:
Configure IPFS to listen for incoming connections on specific network addresses and ports, making the IPFS Gateway and API services accessible. Consider changing addresses and ports depending on the specifics of your network.
Start the IPFS daemon:
Configure Client Nodes
Copy the swarm.key
file from the bootstrap node to client nodes into the ~/.ipfs/
folder and initialize IPFS:
Apply same config as on bootstrap node and start the daemon:
Done! Now you can check that private IPFS network works properly:
List peers on the bootstrap node. It should list all connected nodes:
Pin some files and check their availability across the network:
Configure the IPFS Daemon as systemd
Service
systemd
ServiceFinally, make the IPFS daemon run at system startup. To do this:
Create new service unit file in the
/etc/systemd/system/
Add following content to the file, replacing
/path/to/your/ipfs/executable
with the actual path
Use which ipfs
command to locate the executable.
Usually path to the executable is /usr/local/bin/ipfs
For security purposes, consider creating a separate user to run the service. In this case, specify its name in the User=
line. Without specifying user, the ipfs service will be launched with root
, which means that you will need to copy the ipfs binary to the /root
directory
Reload and enable the service
Done! Now reboot the machine to ensure that daemon starts correctly. Use
systemctl status ipfs
command to check that service is running:
Configure Bacalhau Nodes
Now to connect your private Bacalhau network to the private IPFS network, the IPFS API address should be specified using the --ipfs-connect
flag. It can be found in the ~/.ipfs/api
file:
Done! Now your private Bacalhau network is connected to the private IPFS network!
Test Configured Networks
To verify that everything works correctly:
Pin the file to the private IPFS network
Run the job, which takes the pinned file as input and publishes result to the private IPFS network
View and download job results
Create and Pin Sample File
Create any file and pin it. Use the ipfs add
command:
Run a Bacalhau Job
Run a simple job, which fetches the pinned file via its CID, lists its content and publishes results back into the private IPFS network:
View and Download Job Results
Use bacalhau job describe command to view job execution results:
Use bacalhau job get command to download job results. In this particular case, ipfs
publisher was used, so the get command will print the CID
of the job results:
Use the ipfs ls
command to view the results:
Use the ipfs cat
command to view the file content. In our case, the file of interest is the stdout
:
Use the ipfs get
command to download the file using its CID:
Need Support?
For questions and feedback, please reach out in our Slack