After you create and test a basic Cloud Assembly blueprint, you expand it into a multiple tier application that is deployable to development, test, and eventually production.

To expand the blueprint, you add the following enhancements.

  • An option to cluster application servers for increased capacity

  • A public-facing network and load balancer in front of the application servers

  • A backup server with archive storage

Prerequisites

Create the basic blueprint and test it. See WordPress use case: create a basic blueprint and WordPress use case: test a basic blueprint.

Procedure

  1. Click Blueprints, and open the WordPress-BP blueprint.

    The basic blueprint appears, in the design canvas and YAML code editor.

  2. Make additions and changes, using the code example and figure for guidance.

    You use the GUI to drag new components to the canvas, such as the load balancer, and then finish the configuration in the code editor.

    1. Add a count input prompt to make the WordPress application server into a cluster.
    2. Add a cloud agnostic load balancer.
    3. Connect the load balancer to the WordPress application server cluster.
    4. Add a cloud agnostic backup machine.
    5. Add an implicit dependency between the backup machine and WordPress application server cluster.
    6. Connect the backup machine to the private/internal network.
    7. Add a cloud agnostic public/external network.
    8. Connect the load balander to the public network.
    9. Add a cloud agnostic storage volume for use as an archive disk.
    10. Connect the archive disk to the backup machine.
    11. Add an archiveusage input prompt for the storage disk speed.
    12. Add an archiveDiskSize input prompt for the storage disk size.

      All components

  3. Deploy, test, and make changes in the same way that you did for the basic blueprint.

    You can update existing deployments, or even deploy new instances so that you can compare deployments.

    The goal is to reach a solid, repeatable blueprint that can be used for production deployments.

Completed Expanded Blueprint Code Example

inputs:
  env:
    type: string
    enum:
      - 'env:dev'
      - 'env:prod'
      - 'env:test'
    default: 'env:dev'
    title: Environment
    description: Target Environment
  size:
    type: string
    enum:
      - small
      - medium
      - large
    description: Size of Nodes
    title: Tier Machine Size
  username:
    type: string
    minLength: 4
    maxLength: 20
    pattern: '[a-z]+'
    title: Database Username
    description: Database Username
  userpassword:
    type: string
    pattern: '[a-z0-9A-Z@#$]+'
    encrypted: true
    title: Database Password
    description: Database Password
  databaseDiskSize:
    type: number
    default: 4
    maximum: 10
    title: MySQL Data Disk Size
    description: Database Disk Size
  count:
    type: integer
    default: 2
    maximum: 5
    minimum: 2
    title: WordPress Cluster Size
    description: WordPress Cluster Size (Number of Nodes)
  archiveDiskSize:
    type: number
    default: 4
    maximum: 10
    title: WordPress Archive Disk Size
    description: Archive Storage Disk Speed
  archiveusage:
    type: string
    enum:
      - 'usage:general'
      - 'usage:fast'
    description: Archive Storage Disk Speed
    title: Archive Disk Speed
resources:
  DBTier:
    type: Cloud.Machine
    metadata:
      layoutPosition:
        - 0
        - 0
    properties:
      name: mysql
      image: ubuntu-16
      flavor: '${input.size}'
      constraints:
        - tag: '${input.env}'
      networks:
        - name: '${WP-Network-Private.name}'
          assignPublicIpAddress: true
      remoteAccess:
        authentication: usernamePassword
        username: '${input.username}'
        password: '${input.userpassword}'
      cloudConfig: |
        #cloud-config
        repo_update: true
        repo_upgrade: all

        packages:
         - mysql-server

        runcmd:
         - sed -e '/bind-address/ s/^#*/#/' -i /etc/mysql/mysql.conf.d/mysqld.cnf
         - service mysql restart
         - mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysqlpassword';"
         - mysql -e "FLUSH PRIVILEGES;"
      attachedDisks: []
  WebTier:
    type: Cloud.Machine
    metadata:
      layoutPosition:
        - 0
        - 1
    properties:
      name: wordpress
      flavor: '${input.size}'
      image: 'ubuntu-16'
      count: '${input.count}'
      constraints:
        - tag: '${input.env}'
      networks:
        - name: '${WP-Network-Private.name}'
          assignPublicIpAddress: true
      storage:
        disks:
          - capacityGb: '${input.archiveDiskSize}'
            name: ArchiveDisk
      cloudConfig: |
        #cloud-config
        repo_update: true
        repo_upgrade: all

        packages:
         - apache2
         - php
         - php-mysql
         - libapache2-mod-php
         - php-mcrypt
         - mysql-client

        runcmd:
         - mkdir -p /var/www/html/mywordpresssite && cd /var/www/html && wget https://wordpress.org/latest.tar.gz && tar -xzf /var/www/html/latest.tar.gz -C /var/www/html/mywordpresssite --strip-components 1
         - i=0; while [ $i -le 10 ]; do mysql --connect-timeout=3 -h ${DBTier.networks[0].address} -u root -pmysqlpassword -e "SHOW STATUS;" && break || sleep 15; i=$((i+1)); done
         - mysql -u root -pmysqlpassword -h ${DBTier.networks[0].address} -e "create database wordpress_blog;"
         - mv /var/www/html/mywordpresssite/wp-config-sample.php /var/www/html/mywordpresssite/wp-config.php
         - sed -i -e s/"define('DB_NAME', 'database_name_here');"/"define('DB_NAME', 'wordpress_blog');"/ /var/www/html/mywordpresssite/wp-config.php && sed -i -e s/"define('DB_USER', 'username_here');"/"define('DB_USER', 'root');"/ /var/www/html/mywordpresssite/wp-config.php && sed -i -e s/"define('DB_PASSWORD', 'password_here');"/"define('DB_PASSWORD', 'mysqlpassword');"/ /var/www/html/mywordpresssite/wp-config.php && sed -i -e s/"define('DB_HOST', 'localhost');"/"define('DB_HOST', '${DBTier.networks[0].address}');"/ /var/www/html/mywordpresssite/wp-config.php
         - service apache2 reload
  LoadBalancer:
    type: Cloud.LoadBalancer
    metadata:
      layoutPosition:
        - 0
        - 2
    properties:
      name: myapp-lb
      network: '${WP-Network-Public.name}'
      instances:
        - '${WebTier.id}'
      routes:
        - protocol: HTTP
          port: '80'
          instanceProtocol: HTTP
          instancePort: '80'
          healthCheckConfiguration:
            protocol: HTTP
            port: '80'
            urlPath: /mywordpresssite/wp-admin/install.php
            intervalSeconds: 6
            timeoutSeconds: 5
            unhealthyThreshold: 2
            healthyThreshold: 2
      internetFacing: true
  WP-Network-Private:
    type: Cloud.Network
    metadata:
      layoutPosition:
        - 1
        - 0
    properties:
      name: WP-Network-Private
      networkType: existing
      constraints:
        - tag: 'type:isolated-net'
        - tag: '${input.env}'
  WP-Network-Public:
    type: Cloud.Network
    metadata:
      layoutPosition:
        - 2
        - 0
    properties:
      name: WP-Network-Public
      networkType: public
      constraints:
        - tag: 'type:public-net'
        - tag: '${input.env}'
  backup:
    type: Cloud.Machine
    metadata:
      layoutPosition:
        - 0
        - 3
    properties:
      name: backup
      flavor: '${input.size}'
      image: 'ubuntu-16'
      connectedTo: '${WebTier.address}'
      networks:
        - name: '${WP-Network-Private.name}'
      constraints:
        - tag: '${input.env}'
      attachedDisks:
        - source: '${ArchiveDisk.id}'
  ArchiveDisk:
    type: Cloud.Volume
    metadata:
      layoutPosition:
        - 0
        - 4
    properties:
      name: ArchiveDisk
      capacityGb: 5
      constraints:
        - tag: '${input.archiveusage}'
        - tag: '${input.env}'

What to do next

Define your own infrastructure and create your own blueprints.

See Learn more about setting up the provisioning infrastructure and Learn more about creating Cloud Assembly blueprints.