Two of the most exciting technologies around today are the blockchain and containers. They are both new, powerful and have an amazing ecosystem with many powerful tools available.
However getting started can often be quite a journey wading through dependency after dependency and editing configuration file after file. If you just want to experiment and quickly run some examples or test out a new application then you need a way to automate the process. These two tools, Tendermint MintNet and Clocker, the Container service for Apache Brooklyn, let you do exactly that.
Tendermint is a blockchain application framework, to help you build your own applications that use the underlying distributed consensus technology for blockchain transactions. Clocker is an application management system for Docker containers using Apache Brooklyn and jclouds to design, deploy and manage your application on a cloud-hosted Docker environment.
First, you will need to install and run Apache Brooklyn with the Clocker container service. The easiest way to do this is to use the pre-built Clocker distribution, available on GitHub. (Alternatively, Cloudsoft AMP is a commercially supported distribution of the application management platform which can be downloaded from the Cloudsoft website.)
% wget https://github.com/brooklyncentral/clocker/releases/download/v1.1.0/brooklyn-clocker-dist.tar.gz % tar zxf brooklyn-clocker-dist.tar.gz % cd brooklyn-clocker % ./bin/clocker.sh ...
Now, you need to start a Clocker cluster. Let’s create a four-host system on SoftLayer, using the following blueprint. We’ll use SoftLayer, but Amazon, GCE, OpenStack and more are all supported. Be sure to substitute your own cloud credentials and SSH keys. For examples using other clouds, look at the sample blueprints in the Clocker repository.
location: jclouds:softlayer: region: ams01 identity: IDENTITY credential: CREDENTIAL services: - type: docker-cloud-calico brooklyn.config: entity.dynamicLocation.name: "calico-docker-cloud" docker.host.cluster.initial.size: 4 docker.hostname.customizer: true calico.ipip: false calico.nat: false
This blueprint creates a four VM cluster running Docker Engine with the Calico SDN installed as a libnetwork plugin. To deploy it, go to the Composer tab in the Clocker UI and paste it into the text box. If you are using a different blueprint, you can drag a YAML file there to use it instead. Then, simply click the Deploy button.
After around five to fifteen minutes, depending on your choice of cloud, the VMs will be provisioned and the software deployed and the Clocker cluster will be available. You should see something like this in the UI.
Clocker with Calico in AMP
Now, you can deploy application blueprints to Clocker, and it will manage the process of creating containers and attaching them to networks, using the underlying Apache Brooklyn technology. In the next section we will see how to use Clocker to deploy and manage a Tendermint Blockchain application.
Deploying a MintNet application
The Tendermint MintNet project is a simple way of creating and running blockchain applications. A MintNet application is a cluster of nodes, each running several Docker containers with the different MintNet components. It uses the TMSP protocol to communicate between nodes, and provides a JSON endpoint to access the blockchain data.
Each node has four containers, these are a common data container used to provide the application configuration, a data store container with the MerkleEyes store, the Tendermint application being deployed and the MintNet node container. We have developed a Brooklyn catalog entry that describes this architecture, available as tendermint-mintnet.bom.
To show how this works, we will deploy one of the MintNet example applications. This requires a blueprint that references the catalog entry and configures MintNet with the appropriate startup scripts. Here we will use the basecoin application. The blueprint looks like this.
location: calico-docker-cloud services: - type: tendermint-mintnet id: tendermint-mintnet-basecoin name: "Tendermint MintNet Basecoin Cluster" brooklyn.config: tendermint.node.count: 4 tendermint.application.name: "basecoin" tendermint.chainid: "base" tendermint.application.archive: "https://s3-eu-west-1.amazonaws.com/brooklyn-tendermint/basecoin.tgz"
The tendermint.application.archive configuration points to the archive containing the basecoin init.sh scripts for each container. The Tendermint catalog entry will use these to start the containers, as well as creating the required private and public keys and the initial genesis.json configuration file for the application.
To install the Tendermint catalog entry, paste the contents of tendermint-mintnet.bom into the Composer tab of the Clocker UI, and then select Catalog and click the Deploy Catalog Entry button. You will be redirected to the Catalog tab, where the available catalog entries are listed. Now, return to the Composer tab and paste the basecoin blueprint shown above and click Deploy. This will deploy four Tendermint nodes, one on each of the provisioned Docker VMs. These nodes will have four containers each, which you will be able to see starting if you inspect the entity tree in the Applications tab of the UI. Again, depending on the type of cloud you have deployed the VMs to, this will take a few minutes to start up, as the containers download the tendermint code and run their startup scripts. Eventually you will see the application has started, and the UI will look something like this:
If you click on the URL shown in the Summary tab of the MintNet Basecoin Application entity, you will be able to access the JSON API for Tendermint, which allows you to view the blockchain status, and the status of the MintNet network. The following video shows the process from start to finish.
To find out more about the tendermint blueprints, you can view the cloudsoft/brooklyn-tendermint GitHub repository, which contains the files referenced in this post. The latest version of Clocker is also available on GitHub in the brooklyncentral/clocker repository. Please submit any issues or pull requests with changes to these repositories, and let us know how you get on with the examples.