cloudsoft.io

Compose a 3-tier Application (UI)

Objectives

In this tutorial we will show you how to use the AMP UI to deploy a three-tier web application.

Pre-requisites

This tutorial assumes you have installed Cloudsoft AMP.

Instructions

Select the Blueprint Composer from the Home page or the module menu on the top right of the screen. This module is composed of 4 main parts:

  • The canvas: this is where is displayed the graphical representation of the blueprint you are creating.
  • The floating panel: that is the box on the left which shows different information based on the context:
    • A palette to choose and add entities/policies/enrichers.
    • The spec editor to view and edit the currently selected node.

Blueprint composer - Main view

The top node represents the application node. This is usually where you will set the location for the entire blueprint, unless you wish to deploy parts on different clouds.

Adding the database tier (MySQL)

Add a node for the database by clicking the “plus” icon below the application node (by hovering over it). The floating panel will display the palette where you can either browse through the entire entities catalog, or search by name or the full type name, i.e. org.apache.brooklyn.entity.database.mysql.MySqlNode.

Once the entity is selected, a new node will appear on the graph and the floating panel will then display the spec editor where you can configure it. Set a name by entering My DB (MySQL) instead of Unnamed Entity. Do the same for the ID by entering db instead of No reference ID. Finally, set the configuration key Creation script template URL (datastore.creation.script.url) to the following value:

https://raw.githubusercontent.com/apache/brooklyn-library/master/examples/simple-web-cluster/src/main/resources/visitors-creation-script.sql
Tip: Configuration keys can be filtered by name and type. These options are available when clicking on icon next to the icon.

Your screen should now look like something similar to this:

Blueprint composer - Step 1

Adding the web tier (Cluster of Tomcat)

Add a node for the web cluster by clicking the “plus” icon below the application node (by hovering over it). The floating panel will display again the palette. Look for the entity DynamicCluster or the full type name, i.e. org.apache.brooklyn.entity.group.DynamicCluster and select it.

A new node will appear on the graph and the floating panel will then display the spec editor where you can configure it. Set a name by entering My Cluster instead of Unnamed Entity. Do the same for the ID by entering cluster instead of No reference ID.

On the Configuration accordion, set the suggested Initial size (cluster.initial.size) configuration key to: 2.

Tip: You can also display all available configuration keys by clicking on and select the filter all.

Set the Member spec (dynamiccluster.memberspec) configuration key by clicking on No spec set. The palette will once again be displayed. Select Tomcat 8 Server (full name: org.apache.brooklyn.entity.webapp.tomcat.Tomcat8Server) and enter the following configuration keys (Configuration accordion):

  • wars.root with value

    http://search.maven.org/remotecontent?filepath=org/apache/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.9.0/brooklyn-example-hello-world-sql-webapp-0.9.0.war
    
  • java.sysprops => Add a key brooklyn.example.db.url. For its value, you can either:

    • use the DSL editor by clicking on the lightning bolt icon. This will open up the DSL editor. Select the kind Formatted string then add:

      • jdbc:%s%s?user=%s&password=%s as pattern
      • again, you can set the value of argument 1 manually to $brooklyn:component("db").attributeWhenReady("datastore.url") but a better way is to click on the DSL button and select the datastore.url sensor or the db entity and clicking on the Done button
      • visitors as argument 2
      • brooklyn as argument 3
      • br00k11n as argument 4

      Finally, click on the Done button at the bottom.

    • enter the full DSL value:

      $brooklyn:formatString("jdbc:%s%s?user=%s&password=%s", $brooklyn:component("db").attributeWhenReady("datastore.url"), "visitors", "brooklyn", "br00k11n")
      

The spec editor should now display something similar to this:

Blueprint composer - Spec editor for the web node - member spec

Go back to the web cluster entity by clicking on the My Cluster title on top on the floating panel or by selecting the cluster node on the graph. Head over the Enrichers accordion and click on the “+” icon. Similar to the cluster member spec in the previous step, search and select the Aggregator enricher and add the following configuration keys (Configuration accordion):

  • enricher.sourceSensor => $brooklyn:sensor("webapp.reqs.perSec.windowed")
  • enricher.targetSensor => $brooklyn:sensor("webapp.reqs.perSec.perNode")
  • enricher.aggregating.fromMembers => true

The canvas and the spec viewer should now display something similar to this:

Blueprint composer - Step 2

Adding the load-balancer tier (Nginx)

Add a node for the web cluster by clicking the “plus” icon below the application node (by hovering over it). The floating panel will display again the palette. Look for the entity Nginx Server or the full type name, i.e. org.apache.brooklyn.entity.group.DynamicCluster and select it.

Set a name by entering My Load Balancer (nginx) instead of Unnamed Entity. Do the same for the ID by entering nginx instead of No reference ID.

On the Configuration accordion, search for:

  • loadbalancer.serverpool configuration key and enter the following value: $brooklyn:entity("cluster")
  • nginx.sticky configuration key and uncheck the checkbox

The canvas and the spec viewer should now display something similar to this:

Blueprint composer - Step 3

Setting the application title, location and propagate valuable sensor

Click on the application node (where it currently says New application) to bring up the spec editor. Set a name by entering My Web Cluster instead of Unnamed Application.

Open the Location accordion and click on the Attach link. This will display the palette with all available locations you can deploy your blueprint to. Select the one you wish to use.

Finally, head over the Enrichers and click on the “+” icon. Similar to the cluster member spec in the previous step, search and select the Propagator enricher and add the following configuration keys (Configuration accordion):

  • enricher.producer => $brooklyn:entity("nginx") (or use the DSL editor to target the nginx entity)
  • enricher.propagating.inclusions => add:
    • main.uri
    • main.uri.mapped.subnet
    • main.uri.mapped.public

The canvas and the spec viewer should display something similar to this:

Blueprint composer - Step 4

Summary

The blueprint composer allows you to create and quickly compose applications with graphical visualisation of their status.

Next