| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| |
| brooklyn.catalog: |
| version: "0.13.0-SNAPSHOT" # BROOKLYN_VERSION |
| itemType: entity |
| items: |
| - id: org.apache.brooklyn.entity.webapp.nodejs.NodeJsWebAppService |
| iconUrl: classpath:///nodejs-logo.png |
| item: |
| type: org.apache.brooklyn.entity.webapp.nodejs.NodeJsWebAppService |
| name: Node.JS Application |
| - id: org.apache.brooklyn.entity.webapp.jboss.JBoss7Server |
| iconUrl: classpath:///jboss_logo.png |
| item: |
| type: org.apache.brooklyn.entity.webapp.jboss.JBoss7Server |
| name: JBoss Application Server 7 |
| description: AS7 - an open source Java application server from JBoss |
| - id: org.apache.brooklyn.entity.proxy.nginx.UrlMapping |
| item: |
| type: org.apache.brooklyn.entity.proxy.nginx.UrlMapping |
| name: URL Mapping |
| - id: org.apache.brooklyn.entity.webapp.DynamicWebAppFabric |
| item: |
| type: org.apache.brooklyn.entity.webapp.DynamicWebAppFabric |
| name: Dynamic Web App Fabric |
| - id: org.apache.brooklyn.entity.proxy.nginx.NginxController |
| iconUrl: classpath:///nginx-logo.jpeg |
| item: |
| type: org.apache.brooklyn.entity.proxy.nginx.NginxController |
| name: Nginx Server |
| description: A single Nginx server. Provides HTTP and reverse proxy services |
| - id: org.apache.brooklyn.entity.webapp.jboss.JBoss6Server |
| iconUrl: classpath:///jboss_logo.png |
| item: |
| type: org.apache.brooklyn.entity.webapp.jboss.JBoss6Server |
| name: JBoss Application Server 6 |
| description: AS6 - an open source Java application server from JBoss |
| - id: org.apache.brooklyn.entity.webapp.tomcat.Tomcat8Server |
| iconUrl: classpath:///tomcat-logo.png |
| item: |
| type: org.apache.brooklyn.entity.webapp.tomcat.Tomcat8Server |
| name: Tomcat 8 Server |
| - id: org.apache.brooklyn.entity.proxy.LoadBalancerCluster |
| item: |
| type: org.apache.brooklyn.entity.proxy.LoadBalancerCluster |
| name: Load-balanced Cluster |
| description: | |
| A cluster of load balancers; configuring the cluster (through the LoadBalancer interface) |
| will configure all load balancers in the cluster. |
| - id: org.apache.brooklyn.entity.webapp.jetty.Jetty6Server |
| iconUrl: classpath:///jetty-logo.png |
| item: |
| type: org.apache.brooklyn.entity.webapp.jetty.Jetty6Server |
| name: Jetty6 Server |
| description: Old version (v6 @ Mortbay) of the popular Jetty webapp container |
| - id: org.apache.brooklyn.entity.webapp.DynamicWebAppCluster |
| item: |
| type: org.apache.brooklyn.entity.webapp.DynamicWebAppCluster |
| name: Dynamic Web-app Cluster |
| description: A cluster of web-apps, which can be dynamically re-sized; this does not include a load-balancer |
| - id: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer |
| iconUrl: classpath:///tomcat-logo.png |
| item: |
| type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer |
| name: Tomcat 7 Server |
| - id: org.apache.brooklyn.entity.dns.geoscaling.GeoscalingDnsService |
| iconUrl: classpath:///geoscaling-logo.gif |
| item: |
| type: org.apache.brooklyn.entity.dns.geoscaling.GeoscalingDnsService |
| name: Geoscaling DNS Service |
| description: A geo-DNS service using geoscaling.com |
| - id: org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppCluster |
| item: |
| type: org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppCluster |
| name: Controlled Dynamic Web-app Cluster |
| description: A cluster of load-balanced web-apps, which can be dynamically re-sized |
| |
| - id: load-balancer |
| iconUrl: classpath:///nginx-logo.jpeg |
| item: |
| type: org.apache.brooklyn.entity.proxy.nginx.NginxController |
| name: Load Balancer (nginx) |
| description: | |
| Synonym for 'Nginx Server'. |
| Create a load balancer which will point at members in the group entity |
| referred to by the config key "serverPool". |
| The sensor advertising the port can be configured with the "member.sensor.portNumber" config key, |
| defaulting to `http.port`; all member entities which have published "service.up" will then be picked up. |
| |
| - id: resilient-bash-web-cluster-template |
| itemType: template |
| name: "Template: Resilient Load-Balanced Bash Web Cluster with Sensors" |
| description: | |
| Sample YAML to provision a cluster of the bash/python web server nodes, |
| with sensors configured, and a load balancer pointing at them, |
| and resilience policies for node replacement and scaling |
| item: |
| name: Resilient Load-Balanced Bash Web Cluster (Brooklyn Example) |
| |
| # this final example shows some of the advanced functionality: |
| # defining custom sensors, and a cluster with a "spec", |
| # policies for resilience and scaling based on that sensor, |
| # and wiring a load balancer in front of the cluster |
| |
| # combining this with the riak cluster in the previous example |
| # is left as a suggested exercise for the user |
| |
| services: |
| |
| # define a cluster of the web nodes |
| - type: cluster |
| name: Cluster of Bash Web Nodes |
| id: my-web-cluster |
| brooklyn.config: |
| initialSize: 1 |
| memberSpec: |
| $brooklyn:entitySpec: |
| # template bash-web-server-template is used as the spec for items in this cluster |
| # with a new message overwriting the previous, |
| # and a lot of sensors defined |
| type: bash-web-server-template |
| name: My Bash Web Server VM with Sensors |
| # and clear the location defined there so it is taken from this template |
| locations: [] |
| |
| brooklyn.config: |
| my.message: "part of the cluster" |
| |
| brooklyn.initializers: |
| # make a simple request-count sensor, by counting the number of 200 responses in output.txt |
| - type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor |
| brooklyn.config: |
| name: reqs.count |
| targetType: int |
| period: 5s |
| command: "cat output.txt | grep HTTP | grep 200 | wc | awk '{print $1}'" |
| # and publish the port as a sensor so the load-balancer can pick it up |
| - type: org.apache.brooklyn.core.sensor.StaticSensor |
| brooklyn.config: |
| name: app.port |
| targetType: int |
| static.value: $brooklyn:config("my.app.port") |
| |
| brooklyn.enrichers: |
| # derive reqs.per_sec from reqs.count |
| - type: org.apache.brooklyn.enricher.stock.YamlTimeWeightedDeltaEnricher |
| brooklyn.config: |
| enricher.sourceSensor: reqs.count |
| enricher.targetSensor: reqs.per_sec |
| enricher.delta.period: 1s |
| # and take an average over 30s for reqs.per_sec into reqs.per_sec.windowed_30s |
| - type: org.apache.brooklyn.enricher.stock.YamlRollingTimeWindowMeanEnricher |
| brooklyn.config: |
| enricher.sourceSensor: reqs.per_sec |
| enricher.targetSensor: reqs.per_sec.windowed_30s |
| enricher.window.duration: 30s |
| |
| brooklyn.policies: |
| # restart if a failure is detected (with a max of one restart in 2m, sensor will propagate otherwise) |
| - type: org.apache.brooklyn.policy.ha.ServiceRestarter |
| brooklyn.config: |
| failOnRecurringFailuresInThisDuration: 2m |
| |
| # back at the cluster, create a total per-sec and some per-node average |
| brooklyn.enrichers: |
| - type: org.apache.brooklyn.enricher.stock.Aggregator |
| brooklyn.config: |
| enricher.sourceSensor: reqs.per_sec |
| enricher.targetSensor: reqs.per_sec |
| transformation: sum |
| - type: org.apache.brooklyn.enricher.stock.Aggregator |
| brooklyn.config: |
| enricher.sourceSensor: reqs.per_sec |
| enricher.targetSensor: reqs.per_sec.per_node |
| transformation: average |
| - type: org.apache.brooklyn.enricher.stock.Aggregator |
| brooklyn.config: |
| enricher.sourceSensor: reqs.per_sec.windowed_30s |
| enricher.targetSensor: reqs.per_sec.windowed_30s.per_node |
| transformation: average |
| |
| brooklyn.policies: |
| # resilience: if a per-node restart policy fails, |
| # just throw that node away and create a new one |
| - type: org.apache.brooklyn.policy.ha.ServiceReplacer |
| |
| # and scale based on reqs/sec |
| - type: org.apache.brooklyn.policy.autoscaling.AutoScalerPolicy |
| brooklyn.config: |
| # scale based on reqs/sec (though in a real-world situation, |
| # reqs.per_sec.windowed_30s.per_node might be a better choice) |
| metric: reqs.per_sec.per_node |
| |
| # really low numbers, so you can trigger a scale-out just by hitting reload a lot |
| metricUpperBound: 3 |
| metricLowerBound: 1 |
| |
| # sustain 3 reqs/sec for 2s and it will scale out |
| resizeUpStabilizationDelay: 2s |
| # only scale down when sustained for 1m |
| resizeDownStabilizationDelay: 1m |
| |
| maxPoolSize: 10 |
| |
| # and add a load-balancer pointing at the cluster |
| - type: load-balancer |
| id: load-bal |
| brooklyn.config: |
| # point this load balancer at the cluster, specifying port to forward to |
| loadbalancer.serverpool: $brooklyn:entity("my-web-cluster") |
| member.sensor.portNumber: app.port |
| # disable sticky sessions to allow easy validation of balancing via browser refresh |
| nginx.sticky: false |
| |
| brooklyn.enrichers: |
| # publish a few useful info sensors and KPI's to the root of the app |
| - type: org.apache.brooklyn.enricher.stock.Propagator |
| brooklyn.config: |
| uniqueTag: propagate-load-balancer-url |
| producer: $brooklyn:entity("load-bal") |
| propagating: |
| - main.uri |
| - type: org.apache.brooklyn.enricher.stock.Propagator |
| brooklyn.config: |
| uniqueTag: propagate-reqs-per-sec |
| producer: $brooklyn:entity("my-web-cluster") |
| propagating: |
| - reqs.per_sec |
| - reqs.per_sec.windowed_30s.per_node |
| |
| location: |
| jclouds:aws-ec2: |
| # edit these (or delete if credentials specified in brooklyn.properties) |
| identity: <REPLACE> |
| credential: <REPLACE> |
| |
| region: eu-central-1 |
| minRam: 2gb |