cloud application blueprints with apache brooklyn by alex henevald
DESCRIPTION
So you have your cloud running, what now? Extend the devops agility from infrastructure to applications by learning how to use Brooklyn, the Apache-incubating project for application management. Create blueprints for applications to enable one-click deployment into Cloudstack, Docker, localhost, or other targets. Leverage your favourite server management tools, from Bash to Chef. Automatically change the deployment after it's deployed. Attach policies to support scaling, failover, and alerting in the way your application needs. In this session we'll show how with just a few lines of YAML, you can build powerful application blueprints by composing pre-existing components, from polyglot web stacks to big data tools such as Riak. We'll also cover defining new blueprints using custom scripts, configuring machine selection and runtime policies, and managing new locations such as Clocker -- the cloud of docker. About Alex Henevald Alex brings twenty years experience designing software solutions in the enterprise, start-up, and academic sectors. Most recently Alex was with Enigmatec Corporation where he led the development of what is now the Monterey® Middleware Platform™. Previous to that, he founded PocketWatch Systems, commercialising results from his doctoral research. Alex holds a PhD (Informatics) and an MSc (Cognitive Science) from the University of Edinburgh and an AB (Mathematics) from Princeton University. Alex was both a USA Today Academic All-Star and a Marshall Scholar.TRANSCRIPT
Application Management with Apache Brooklyn
Alex Heneveld @ahtweetin CTO & Co-Founder, Cloudsoft Committer, Apache Brooklyn Build-a-Cloud Day Vegas, Oct 2014
© 2014 Cloudsoft Corporation
Mission
2
!!
Simplify application deployment and managementwith composable blueprints,
leveraging the best tools for server config, cloud, and monitoring.
!Apache Brooklyn is the only autonomic open source
multi-cloud application management platform. !
© 2014 Cloudsoft Corporation
Blueprints
The Brooklyn Approach
push-button deployment
The Brooklyn Approach
ongoing management
The Brooklyn Approach
open extensible framework
The Brooklyn Approach
Benefits — Agility
Benefits — Reliability
autonomic management
built-in!
Benefits — Transparency
Benefits — Community
© 2014 Cloudsoft Corporation
Multi-Tier Application — Blueprint YAML
11
services:- type: WebAppCluster brooklyn.config: wars.root: hello-db.war http.port: 8080+ java.sysprops: db.url: $brooklyn:component("db"). attributeWhenReady("database.url")
- type: MySqlNode id: db brooklyn.config: creation.script: hello-db.sql
name: MyWebCluster
© 2014 Cloudsoft Corporation
Multi-Tier Application — Blueprint YAML
12
- type: MySqlNode id: db brooklyn.config: creation.script: hello-db.sql
name: MyWebCluster
policies: - type: AutoScaler sensor: webapp.reqs.sec range: [100,200]
services:- type: WebAppCluster brooklyn.config: wars.root: hello-db.war http.port: 8080+ java.sysprops: db.url: $brooklyn:component("db"). attributeWhenReady("database.url")
© 2014 Cloudsoft Corporation
Multi-Tier Application — Blueprint YAML
13
- type: MySqlNode id: db brooklyn.config: creation.script: hello-db.sql
name: MyWebCluster
policies: - type: AutoScaler sensor: webapp.reqs.sec range: [100,200]
services:- type: WebAppCluster brooklyn.config: wars.root: hello-db.war http.port: 8080+ java.sysprops: db.url: $brooklyn:component("db"). attributeWhenReady("database.url")
location: jclouds:cloudstack:http://10.4.88.16:9999/client/api
© 2014 Cloudsoft Corporation
More Blueprint YAML — Cassandra Cluster
14
name: cassandra-cluster-app!services:- type: brooklyn.entity.nosql.cassandra.CassandraCluster name: Cassandra Cluster brooklyn.config: cluster.initial.size: 5 cluster.initial.quorumSize: 3 provisioning.properties: minCores: 4 minRam: 8192!location: softlayer:sjc01
© 2014 Cloudsoft Corporation
MyWebCluster
15
…
MyWebCluster
ControlledDynamicWebAppCluster
DynamicWebAppCluster
JBoss7Server
NGINX
MySQL
JBoss7Server
Auto Scaler Policy[targets]
© 2014 Cloudsoft Corporation
© 2014 Cloudsoft Corporation 16
Define New Blueprint
public class MyWebCluster extends AbstractApplication implements MyWebClusterConstants { @Override public void init() {!!! // TODO build the application
!!
! }}
Type to enter text
© 2014 Cloudsoft Corporation
© 2014 Cloudsoft Corporation 17
Create App Tier
public class MyWebCluster extends AbstractApplication implements MyWebClusterConstants { @Override public void init() {!!! JBoss7Server web = addChild( EntitySpecs.spec(JBoss7Server.class) .configure(JavaWebAppService.ROOT_WAR, getConfig(WAR_PATH)) );!
! }}
Type to enter
Type to enter text
© 2014 Cloudsoft Corporation
© 2014 Cloudsoft Corporation 18
Configure App Tier
Type to enter
Type to enter text
public class MyWebCluster extends AbstractApplication implements MyWebClusterConstants { @Override public void init() {!!! JBoss7Server web = addChild( EntitySpecs.spec(JBoss7Server.class) .configure(JavaWebAppService.ROOT_WAR, getConfig(WAR_PATH)) .configure(WebAppService.HTTP_PORT, PortRanges.fromString("8080+")) );
! }}
© 2014 Cloudsoft Corporation
© 2014 Cloudsoft Corporation
Add DB Tier
public class MyWebCluster extends AbstractApplication implements MyWebClusterConstants { @Override public void init() { MySqlNode mysql = addChild( EntitySpecs.spec(MySqlNode.class) .configure(MySqlNode.CREATION_SCRIPT_URL, getConfig(DB_SETUP_SQL_URL)) );! JBoss7Server web = addChild( EntitySpecs.spec(JBoss7Server.class) .configure(JavaWebAppService.ROOT_WAR, getConfig(WAR_PATH)) .configure(WebAppService.HTTP_PORT, PortRanges.fromString("8080+")) );
! }}
Type to enter
Type to enter text
© 2014 Cloudsoft Corporation
© 2014 Cloudsoft Corporation
Wire up App and DB Tiers
public class MyWebCluster extends AbstractApplication implements MyWebClusterConstants { @Override public void init() { MySqlNode mysql = addChild( EntitySpecs.spec(MySqlNode.class) .configure(MySqlNode.CREATION_SCRIPT_URL, getConfig(DB_SETUP_SQL_URL)) );! JBoss7Server web = addChild( EntitySpecs.spec(JBoss7Server.class) .configure(JavaWebAppService.ROOT_WAR, getConfig(WAR_PATH)) .configure(WebAppService.HTTP_PORT, PortRanges.fromString("8080+")) .configure(JavaEntityMethods.javaSysProp("brooklyn.example.db.url"), formatString("jdbc:%s%s?user=%s\\&password=%s", attributeWhenReady(mysql, MySqlNode.MYSQL_URL), DB_TABLE, DB_USERNAME, DB_PASSWORD)) );! }}
Type to enter
Type to enter text
© 2014 Cloudsoft Corporation
© 2014 Cloudsoft Corporation
Introduce Elasticity in App Tier
public class MyWebCluster extends AbstractApplication implements MyWebClusterConstants { @Override public void init() { MySqlNode mysql = addChild( EntitySpecs.spec(MySqlNode.class) .configure(MySqlNode.CREATION_SCRIPT_URL, getConfig(DB_SETUP_SQL_URL)) );! ControlledDynamicWebAppCluster web = addChild( EntitySpecs.spec(ControlledDynamicWebAppCluster.class) .configure(JavaWebAppService.ROOT_WAR, getConfig(WAR_PATH)) .configure(WebAppService.HTTP_PORT, PortRanges.fromString("8080+")) .configure(JavaEntityMethods.javaSysProp("brooklyn.example.db.url"), formatString("jdbc:%s%s?user=%s\\&password=%s", attributeWhenReady(mysql, MySqlNode.MYSQL_URL), DB_TABLE, DB_USERNAME, DB_PASSWORD)) );! }}
Type to enter text
Type to enter text
Type to enter
Type
© 2014 Cloudsoft Corporation
© 2014 Cloudsoft Corporation
Customize Elasticity in App Tier
public class MyWebCluster extends AbstractApplication implements MyWebClusterConstants { @Override public void init() { MySqlNode mysql = addChild( EntitySpecs.spec(MySqlNode.class) .configure(MySqlNode.CREATION_SCRIPT_URL, getConfig(DB_SETUP_SQL_URL)) );! ControlledDynamicWebAppCluster web = addChild( EntitySpecs.spec(ControlledDynamicWebAppCluster.class) .configure(JavaWebAppService.ROOT_WAR, getConfig(WAR_PATH)) .configure(WebAppService.HTTP_PORT, PortRanges.fromString("8080+")) .configure(JavaEntityMethods.javaSysProp("brooklyn.example.db.url"), formatString("jdbc:%s%s?user=%s\\&password=%s", attributeWhenReady(mysql, MySqlNode.MYSQL_URL), DB_TABLE, DB_USERNAME, DB_PASSWORD)) .configure(DynamicCluster.INITIAL_SIZE, 2) ); }}
Type to enter text
Type to enter text
Type to enter
Type
Type to enter
© 2014 Cloudsoft Corporation
© 2014 Cloudsoft Corporation
Add Policies and KPI’s
public class MyWebCluster extends AbstractApplication implements MyWebClusterConstants { @Override public void init() { MySqlNode mysql = ...; ControlledDynamicWebAppCluster web = ...; web.addEnricher(HttpLatencyDetector.builder().url(ROOT_URL). rollup(10, SECONDS).build());! web.getCluster().addPolicy(AutoScalerPolicy.builder(). metric(REQUESTS_PER_SECOND_IN_WINDOW_PER_NODE). metricRange(10, 100).sizeRange(2, 5).build());! addEnricher(SensorPropagatingEnricher.newInstanceListeningTo(web, ROOT_URL, REQUESTS_PER_SECOND_IN_WINDOW, REQUEST_LATENCY_IN_SECONDS_IN_WINDOW)); }}
Type to enter text
Type to enter text
Type to enter
Type
Type to enter
Type to enter text
© 2014 Cloudsoft Corporation
© 2014 Cloudsoft Corporation© 2014 Cloudsoft Corporation
Test New Blueprint
24