Apache Brooklyn#

Intro#

Apache Brooklyn is currently an incubating Apache project.

Use (yaml) blueprints to model your application (components) and describe the required infrastructure. But also deploy your app and manage (monitor) your application.

There is a Catalog with components to choose from, or write your own.

It has a nice web ui, but also everything available via REST interfaces.

Resources#

Installation#

Well, that is very easy:

tar -zxf brooklyn-0.7.0-incubating-dist.tar.gz
cd brooklyn-0.7.0-incubating
bin/brooklyn launch

It will log to 2 files in the current directory brooklyn.info.log brooklyn.debug.log. If you have not created a ~/.brooklyn/brooklyn.properties file with special settings, you will get anonymous admin access at http://localhost:8081, but only if you come from localhost. If you come from other hosts (like when you run it in a docker container then you get basic auth), the password is generated each time the server is started and is logged to the brooklyn.info.log file:

2015-08-08 19:12:56,404 INFO  b.r.s.p.BrooklynUserWithRandomPasswordSecurityProvider [brooklyn-jetty-server-8081-qtp1042232199-22]: Allowing access to web console from localhost or with brooklyn:m01u2ll1H2

I decided to run it in a Docker container, the Dockerfile and other stuff are in my private my gitblit.

I also have a Docker container for brooklyn nodes (so we can get very predictable targets for brooklyn).

Both Dockerfiles are "subclassed" from phusion/baseimage.

Using#

Get Started on localhost#

I first followed the get started and the deploying a blueprint, which deploys a MySQL DB, a Tomcat7 server and an nginx frontending webserver, all to localhost.

This went well, but make sure that the user brooklyn can ssh to localhost with pub/priv key, no password and no password phrase, and that this user can sudo su - to do all the necessary stuff (the main reason to run it in a Docker container).

So this went rather smooth, note that in the above example you can run all components (MySQL, Tomcat, nginx) on the same target (location), namely localhost.

Deploy to other hosts #

The next experiment was to deploy to a host other than the host where the brooklyn server is running. So, therefore I fired up a second Docker container, arranged ssh and sudo access to that, and tried to deploy the following blueprint :

name: webnode1

services:

- type: brooklyn.entity.webapp.ControlledDynamicWebAppCluster
  name: My Web
  location:
    byon:
      hosts:
      - brooklyn@172.17.0.76
  brooklyn.config:
    wars.root: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
    java.sysprops:
      brooklyn.example.db.url: >
        $brooklyn:formatString("jdbc:%s%s?user=%s&password=%s",component("db").attributeWhenReady("datastore.url"),"visitors", "brooklyn", "br00k11n")

- type: brooklyn.entity.database.mysql.MySqlNode
  id: db
  name: My DB
  location:
    byon:
      hosts:
      - brooklyn@172.17.0.76
  brooklyn.config:
    creationScriptUrl: https://bit.ly/brooklyn-visitors-creation-script

Which basically is a copy of the previous excercise. Note that 172.17.0.76 is the IP address of the second Docker container brooklyn-node1.

This kept failing with No machines available in FixedListMachineProvisioningLocation.
Googled this, but in general you do not get much results foor Apache Brooklyn. After poking around quite a bit I concluded (not sure) that brooklyn can only run one service per location (except for localhost). So I only added an additional host to the location, and it all worked fine.

Nice to see you get real time stats in your web UI (or REST if you like).

I ran a simple loadtest script against the application's URL, and you nicely see the effects on the stats.

Time for next experiment, autoscaling.

AutoScaling#

We want to be able to automatically scale the number of Tomcat instances, depending on something like response time or request rate.

Run a Tomcat8 server.#

Use pools of locations by name #

We want to use a pool of "servers" by name. I think it can be done by specifying locations in the brooklyn.properties file, and for example having a bunch of Docker containers available.

Miscellaneous#

  1. You can remove an application by selecting it in the left pane, selecting "Advanced" in the right pane, and the choose "Expunge".