Deployment automations

We have a number of automations to facilitate configuring and deploying IPFS Clusters:

Ansible roles

Ansible roles for configuring and deploying ipfs-cluster-service, ipfs-cluster-ctl and go-ipfs (including templated configuration files) are available at https://github.com/hsanjuan/ansible-ipfs-cluster.

Docker

IPFS Cluster provides official dockerized releases at https://hub.docker.com/r/ipfs/ipfs-cluster/ along with an example template for docker-compose.

If you want to run one of the /ipfs/ipfs-cluster Docker containers, it is important to know that:

  • The container does not run go-ipfs and you should run the IPFS daemon separately, for example, using the ipfs/go-ipfs Docker container. The ipfs_connector/ipfshttp/node_multiaddress configuration value will need to be adjusted accordingly to be able to reach the IPFS API. This path supports DNS addresses (/dns4/ipfs1/tcp/5001) and is set from the CLUSTER_IPFSHTTP_NODEMULTIADDRESS environment variable when starting the container and no previous configuration exists.
  • By default, we use the /data/ipfs-cluster as the IPFS Cluster configuration path. We recommend mounting this folder as means to provide custom configurations and/or data persistency for your peers. This is usually achieved by passing -v <your_local_path>:/data/ipfs-cluster to docker run.

The container (Dockerfile here runs an entrypoint.sh script which initializes IPFS Cluster when no configuration is present. The configuration values can be controlled by setting environment variables as explained in the configuration reference.

By default crdt consensus is used to initialize the configuration. This can be overridden by setting IPFS_CLUSTER_CONSENSUS=raft. Similarly, pebble is used as the default backend, and can be overridden setting IPFS_CLUSTER_DATASTORE=badger3 (for example).

Unless you run docker with --net=host, you will need to set $CLUSTER_IPFSHTTP_NODEMULTIADDRESS or make sure the configuration has the correct node_multiaddress.
Unless you run docker with --net=host, the REST API endpoint will only listen locally inside the container. You may need to set $CLUSTER_RESTAPI_HTTPLISTENMULTIADDRESS to /ip4/0.0.0.0/tcp/9096 if you wish to access this endpoint from outside the container, along with the necessary port forwarding (-p 9094:9094.

Docker compose

We also provide an example docker-compose.yml that is able to launch an IPFS Cluster with two Cluster peers and two IPFS daemons running.

During the first launch, configurations are automatically generated and will be persisted for next launches in the ./compose folder, along with the ipfs ones. Delete this folder to reset the Docker Compose setup.

Only the IPFS swarm port (tcp 4001/4101) and the IPFS Cluster API ports (tcp 9094/9194) are exposed out of the containers.

This compose file is provided as an example on how to set up a multi-peer Cluster using Docker containers. You may need to adapt it for your own needs.