You can build on blueprints, adding and modifying components until you are ready to put the application in production. This iterative process

Having created a basic blueprint, you now want to update it with additional components. The first add the load balancer component, verify and test, and then do the same with backup and the archive disk storage.

In the previous procedure, you learned how to use the canvas with the YAML. To complete the WordPress application blueprint, it is expected that you understand these concepts. This procedure will provide the complete YAML, and then provide overview information about the load balancer, the public network, and the iterative deployment process from development to production.

Prerequisites

This procedure uses the basic blueprint and builds on it. See WordPress Use Case: Add a Basic Blueprint.

Procedure

  1. On the Blueprints tab, click the WordPress-BP.

    The design canvas appears with the blueprint topology and YAML.

  2. Add and configure additional components.

    Update each of the following components using the information provided in the example below.

    1. Add a Cloud Agnostic backup machine.
    2. Connect the backup machine to the private wpnet.
    3. Add a Cloud Agnostic public network.
    4. Add a Cloud Agnostic load balancer component to use as the myapp-lb load balancer.
    5. Connect the load balancer to the wordpress component.
    6. Connect the load balander to the public network.
    7. Add a Cloud Agnostic storage volume.
    8. Connect the archive disk to the backup machine.

    The resource section of your blueprint resembles the example below.

  3. Add input values for load balancer tags.
     
    archiveusage:
        type: string
        enum:
          - usage:general
          - usage:fast
  4. Deploy the blueprint to test the load balancer.

    You are still deploying the blueprint to your dev environment. In this case, deploy a new instance so that you can compare deployments if necessary.

Results

You created and iteratively built and deployed a sample multi-tier application by adapting the sample infrastructure to your existing cloud resources.





Basic and Added Components YAML Example

The following is the complete blueprint YAML.

inputs:
  size:
    type: string
    enum:
      - small
      - medium
      - large
    description: Size of Nodes
    title: Node Size
  zone:
    type: string
    enum:
      - 'zone:dev'
      - 'zone:test'
      - 'zone:prod'
    description: 'Select the development, testing, or production zone.'
    title: Deployment Zone
  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: Size of Wordpress archive disk
  databaseDiskSize:
    type: number
    default: 4
    maximum: 10
    title: MySQL Data Disk Size
    description: Size of database disk
  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
  archiveusage:
    type: string
    enum:
      - 'usage:general'
      - 'usage:fast'
    description: Select the archive storage disk speed.
    title: Archive Disk Speed
resources:
  DBTier:
    type: Cloud.Machine
    metadata:
      layoutPosition:
        - 0
        - 0
    properties:
      name: mysql
      flavor: '${input.size}'
      image: 'ubuntu-16'
      constraints:
        - tag: '${input.zone}'
      storage:
        disks:
          - capacityGb: '${input.databaseDiskSize}'
            name: DatabaseDisk
      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;"
  WebTier:
    type: Cloud.Machine
    metadata:
      layoutPosition:
        - 0
        - 1
    properties:
      name: wordpress
      flavor: '${input.size}'
      image: 'ubuntu-16'
      count: '${input.count}'
      constraints:
        - tag: '${input.zone}'
      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}'
      constraints:
        - 'tag:''${input.archiveusage}'''
      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.zone}'
  WP-Network-Public:
    type: Cloud.Network
    metadata:
      layoutPosition:
        - 2
        - 0
    properties:
      name: WP-Network-Public
      networkType: public
      constraints:
        - tag: 'type:public-net'
        - tag: '${input.zone}'
  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.zone}'
      attachedDisks:
        - source: '${ArchiveDisk.id}'
  ArchiveDisk:
    type: Cloud.Volume
    metadata:
      layoutPosition:
        - 0
        - 4
    properties:
      name: ArchiveDisk
      capacityGb: 5
      constraints:
        - tag: '${input.archiveusage}'
        - tag: '${input.zone}'

What to do next

Build our your infrastructure and create your own blueprints. See How Do I Set Up the Cloud Assembly Provisioning Infrastructure and How Do I Create and Deploy Cloud Assembly Blueprints.