cloudsoft.io

Blueprint to deploy the metering service

You can use AMP to deploy and manage the metering service using this blueprint:

location: ibm-bluebox-lon-vpn
services:
  - type: org.apache.brooklyn.entity.database.mysql.MySqlNode
    name: MySqlNode
    id: mysql-node
    brooklyn.initializers:
      - type: org.apache.brooklyn.core.sensor.StaticSensor
        brooklyn.config:
          name: microservice.sql.user
          static.value: micro-user
      - type: org.apache.brooklyn.core.sensor.StaticSensor
        brooklyn.config:
          name: microservice.sql.password
          static.value: kjr67GHSGDH2jvnna
      - type: org.apache.brooklyn.core.sensor.StaticSensor
        brooklyn.config:
          name: microservice.host
          static.value: $brooklyn:component("microservice").attributeWhenReady("host.address")

    brooklyn.config:
      pre.install.command: >
        which yum && sudo yum update -y
        which apt-get && sudo apt-get update -y && sudo apt-get upgrade -y
      creationScriptTemplateUrl: #link to freemarker creation template (I.E. creation_script.mysql.ftl)

    provisioning.properties:
      minRam: 4gb
      minCores: 4
      minDisk: 100gb
  - type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
    id: microservice
    name: microservice
    brooklyn.initializers:
      - type: org.apache.brooklyn.core.sensor.StaticSensor
        brooklyn.config:
          name: microservice.admin.user
          static.value: admin
      - type: org.apache.brooklyn.core.sensor.StaticSensor
        brooklyn.config:
          name: microservice.admin.password
          static.value: mypassword
    brooklyn.config:
      download.url: #link to JAR. E.G. artifactory link

      install.command: |
        which java || \
        { sudo apt-get update && sudo apt-get -y install openjdk-7-jre ; } || \
        { sudo yum update && sudo yum install java-1.7.0-openjdk ; } || \
        { echo WARNING: cannot install Java && exit 1 ; }
      #metering-microservice-1.0.jar to be replaced by name of artifact downloaded by download.url statement
      launch.command: |
        $brooklyn:formatString("
        nohup java -jar metering-microservice-1.0.jar \\
        --spring.datasource.username=%s \\
        --spring.datasource.password=%s \\
        --spring.datasource.url=jdbc:%smydb \\
        --security.user.name=%s \\
        --security.user.password=%s &
        ",
        $brooklyn:component("mysql-node").attributeWhenReady("microservice.sql.user"),
        $brooklyn:component("mysql-node").attributeWhenReady("microservice.sql.password"),
        $brooklyn:component("mysql-node").attributeWhenReady("datastore.url"),
        attributeWhenReady("microservice.admin.user"),
        attributeWhenReady("microservice.admin.password")
        )

      checkRunning.command: |
        $brooklyn:formatString("counter=`wget -T 15 -q -O- %s:8080/health --http-user=%s --http-password=%s | grep -c \"status.:.UP\"`; if [ $counter -eq 0 ]; then exit 1; fi",
        $brooklyn:attributeWhenReady("host.address"),
        attributeWhenReady("microservice.admin.user"),
        attributeWhenReady("microservice.admin.password")
        )
    provisioning.properties:
      minRam: 4gb
      minCores: 4
      minDisk: 5gb

Download the YAML file