Connecting ships

One of the nice thing about Armada is that once we have access to one ship (server with Armada agent), we can manage services on any other ship in its Armada cluster.

After installing Armada on a server it becomes one-ship Armada cluster. We can check cluster status with following command:

$ armada info
Ship name Ship role API address API status 192.168.3.141 leader 192.168.3.141:49153 passing WARNING: We cannot survive leader leaving/failure. Such configuration should only be used in development environments.

Ship name by default is the server's IP address.
Ship role is one of leader, commander, ship. If you are familiar with some services using Raft Consensus Algorithm, it directly translates to leader, server (consensus member) and client roles. We won't go into further details right now, as this is explained in one of our Armada guides.
API address is an address through which Armada agents talk to each other.
API status has the same meaning as in armada list command.

We'll deploy another ship right now. Then we'll join it with the first one to form bigger Armada cluster.
You can try running code below on another host, or in some separate directory created for second Vagrant box.

Host: behemot
$ curl -sLO http://vagrant.armada.sh/Vagrantfile
$ vagrant up
$ vagrant ssh
vagrant$ armada info
Ship name Ship role API address API status 192.168.3.177 leader 192.168.3.177:49153 passing WARNING: We cannot survive leader leaving/failure. Such configuration should only be used in development environments.
vagrant$ armada join 192.168.3.141
{u'status': u'ok'}
vagrant$ armada info
Ship name Ship role API address API status 192.168.3.141 leader 192.168.3.141:49153 passing 192.168.3.177 ship 192.168.3.177:49153 passing WARNING: We cannot survive leader leaving/failure. Such configuration should only be used in development environments.

It looks like we have an Armada cluster consisting of two ships! Currently there is no strict limit on the number of ships that can join Armada cluster, so we could continue adding many more.

Running services on remote ships

We'll demonstrate how easy it is to run services on another ship.

First, because our dockyard is available only by non-secure HTTP protocol, we have to add it to Docker's insecure registry list on the remote ship:

Host: behemot
 
$ echo DOCKER_OPTS=\"\$DOCKER_OPTS --insecure-registry 192.168.3.141:10000\" | sudo tee --append /etc/default/docker
$ sudo service docker restart
$ sudo service armada restart

Let's go back to our first ship now.

$ armada run upcase-service --ship 192.168.3.177
Running microservice upcase-service from dockyard: 192.168.3.141:10000 (alias: myrepo) on remote ship: 192.168.3.177... Service is running in container aebd4da2633d available at addresses: 192.168.3.177:49156 (80/tcp)
$ armada list
Name Address ID Status Tags armada 192.168.3.141:49153 ae148a2d3a1a passing - armada 192.168.3.177:49153 ca0f177a32c1 passing - dockyard 192.168.3.141:10000 27cc85f15888 passing - example 192.168.3.141:49156 efe0e1ab41e5 passing - example 192.168.3.141:49158 a9992ef1f772 passing - example 192.168.3.141:49160 fc6776c8f6da passing ['env:funny-service'] upcase-service 192.168.3.141:49166 275a58a771ec passing - upcase-service 192.168.3.177:49156 aebd4da2633d passing -

That's it!

In order for it to be even easier we can give custom names to ships by using command armada name.

Host: behemot
vagrant$ armada name behemot
{u'status': u'ok'}

$ armada info
Ship name Ship role API address API status 192.168.3.141 leader 192.168.3.141:49153 passing behemot ship 192.168.3.177:49153 passing WARNING: We cannot survive leader leaving/failure. Such configuration should only be used in development environments.

The name has been propagated to other ship. Now we could also use armada run upcase-service --ship behemot to run the service on that remote ship without having to remember its IP address.

Other remote commands

A few other Armada commands such as armada stop, armada restart and armada ssh also work on remote ships.

Host: behemot
vagrant$ armada stop upcase-service
Stopping service upcase-service... Service has been stopped.

The above command would work from any ship in our Armada cluster.

Learn more

The best way to learn Armada is by using it. So we recommend deploying it in your local environment first, get to know it and then start using it in production.

If you want to know more about concepts not covered in this tutorial, please go to our guides section.

Also remember that you can always look up Armada command syntax with armada -h.

Fair Winds!