Running services
Now that we have Armada ready, let's try to run a simple service on it. We will use a service called example which lets us see its system environment variables through HTTP api.$ armada run example
Running microservice example from dockyard: dockyard.armada.sh (alias: armada) locally...
Service is running in container 789731dc0ca4 available at addresses:
192.168.3.141:49156 (80/tcp)
$ curl 192.168.3.141:49156
{
"HOSTNAME": "789731dc0ca4",
"MICROSERVICE_APT_GET_UPDATE_DATE": "2014-08-11",
"CEREBRO_BASIC_APT_GET_UPDATE_DATE": "2014-07-14",
"MICROSERVICE_NAME": "example",
"SUPERVISOR_PROCESS_NAME": "example",
"SUPERVISOR_SERVER_URL": "unix:///var/run/supervisor.sock",
"RESTART_CONTAINER_PARAMETERS": "eyJlbnZpcm9ubWVudCI6IHsiTUlDUk9TRVJWSUNFX05BTUUiOiAiZXhhbXBsZSJ9L
CAiY29udGFpbmVyIjogImV4YW1wbGUiLCAicG9ydHMiOiB7fSwgInZvbHVtZXMiOiB7Ii92YXIvcnVuL2RvY2tlci5zb2NrIj
ogIi92YXIvcnVuL2RvY2tlci5zb2NrIn19",
"SUPERVISOR_ENABLED": "1",
"HOME": "/",
"PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"SUPERVISOR_GROUP_NAME": "example"
}
Service environments
Now we'll run another instance of example service with a twist. We'll provide it with extra environment variable by using parameter -e.$ armada run example -e "EXTRA_VARIABLE=crazy-variable-11"
Running microservice example from dockyard: dockyard.armada.sh (alias: armada) locally...
Service is running in container a9992ef1f772 available at addresses:
192.168.3.141:49158 (80/tcp)
$ curl 192.168.3.141:49158
{
"EXTRA_VARIABLE": "crazy-variable-11",
"HOSTNAME": "a9992ef1f772",
...(skipped)...
}
$ armada list
Name Address ID Status Tags
armada 192.168.3.141:49153 ae148a2d3a1a passing -
example 192.168.3.141:49156 789731dc0ca4 passing -
example 192.168.3.141:49158 a9992ef1f772 passing -
Service ID is globally unique id of container with the service.
Status is one of passing, warning, critical depending on service health checks.
Tags are some extra information about a service. Ok, so looking on the list, how do we know which example service is the first and which is the second one? Right now it's easy, but when service catalog grows to many more services it can be much harder. To help us differentiate the service we can use another armada run parameter:
$ armada run example --env funny-service
Running microservice example from dockyard: dockyard.armada.sh (alias: armada) locally...
Service is running in container f7a09fb19009 available at addresses:
192.168.3.141:49160 (80/tcp)
$ armada list
Name Address ID Status Tags
armada 192.168.3.141:49153 ae148a2d3a1a passing -
example 192.168.3.141:49156 789731dc0ca4 passing -
example 192.168.3.141:49158 a9992ef1f772 passing -
example 192.168.3.141:49160 f7a09fb19009 passing ['env:funny-service']
$ curl 192.168.3.141:49160
{
"HOSTNAME": "f7a09fb19009",
"MICROSERVICE_ENV": "funny-service",
...(skipped)...
}
Other fun stuff
So far we have run our example services only on local host. But with Armada running it on some remote host (ship) would be just as simple: armada run example --ship johnny-ship. We'll cover the topic of many ships in one armada in more details later. We have run some services, we obviously also have a way to stop them:$ armada stop 789
Stopping service 789...
Service has been stopped.
$ armada list
Name Address ID Status Tags
armada 192.168.3.141:49153 ae148a2d3a1a passing -
example 192.168.3.141:49158 a9992ef1f772 passing -
example 192.168.3.141:49160 f7a09fb19009 passing ['env:funny-service']