Sample Blueprint for Cloudify Host Pool Example
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
circle.yml
host-pool-vpc-blueprint.yaml
plugin-demo-blueprint.yaml
pool.yaml
service-blueprint.yaml

README.md

Build Status

Cloudify Host Pool Service and Plugin Example

This will help you set up a demo environment using the Cloudify Host Pool Service and Plugin

Specifically:

  • One VM for the Host Pool Service
  • Five VMs for the Host Pool itself
  • a VPC
  • a Subnet
  • an Internet Gateway
  • a Security Group in the VPC
  • a Keypair

Requirements

  • You need Cloudify 3.3.1 CLI installed and your AWS Credentials (If you have other VMs, it's fine to replace.)
  • You will need the jq command line tool parsing some JSON.
  • You need these directories in this work directory:
    • mkdir deploy_infra
    • mkdir plugin_test

Install the infrastructure

You don't need to do this step if you already have infrastructure in place.

(cd deploy_infra && cfy local init -p ../host-pool-vpc-blueprint.yaml -i '
aws_access_key_id: YOUR-AWS-CREDS
aws_secret_access_key: YOUR-AWS-CREDS
' && cfy local execute -w install --task-retries=9 --task-retry-interval=9
)

Set up the service for the infrastructure

Find out the key path and move it to the blueprint directory:

(cd deploy_infra && cfy local outputs | jq '.ServiceEndpoint.key_path')
mv ~/host-pool-demo-key.pem . # Change this if you changed it.

Insert the IPs of your Host Pool Instances into your pool.yaml:

(cd deploy_infra &&
n=0;
for i in `cfy local instances --node-id=host_pool_demo_hosts | jq '.[].runtime_properties.public_ip_address' | sed s/\"//g`;
do
echo "
  - name: server$n
    endpoint:
      ip: $i" >> ../pool.yaml;
n=$((n+1));
done
)

Let's do something a little weird and SSH into our service VM and install Cloudify CLI.

Change the "ubuntu" below to another user, if you have a different default user on the target machine.

ssh -i host-pool-demo-key.pem ubuntu@`cd deploy_infra && cfy local outputs | jq '.ServiceEndpoint.ip' | sed s/\"//g`
sudo apt-get update -y
curl -O -L http://gigaspaces-repository-eu.s3.amazonaws.com/org/cloudify3/get-cloudify.py && sudo python get-cloudify.py -f --install-pip --install-virtualenv --virtualenv cloudify
source cloudify/bin/activate
cfy -h # just to test
exit

Service Installation

First lets copy some files over.

scp -i host-pool-demo-key.pem host-pool-demo-key.pem ubuntu@`cd deploy_infra && cfy local outputs | jq '.ServiceEndpoint.ip' | sed s/\"//g`:~/
scp -i host-pool-demo-key.pem pool.yaml ubuntu@`cd deploy_infra && cfy local outputs | jq '.ServiceEndpoint.ip' | sed s/\"//g`:~/
scp -i host-pool-demo-key.pem service-blueprint.yaml ubuntu@`cd deploy_infra && cfy local outputs | jq '.ServiceEndpoint.ip' | sed s/\"//g`:~/

Now, let's install.

ssh -i host-pool-demo-key.pem ubuntu@`cd deploy_infra && cfy local outputs | jq '.ServiceEndpoint.ip' | sed s/\"//g`
source cloudify/bin/activate
cfy local init -p service-blueprint.yaml
cfy local execute -w install
exit

To test that the install worked, run a simple request:

curl http://`cd deploy_infra && cfy local outputs | jq '.ServiceEndpoint.ip' | sed s/\"//g`:8080/hosts

Plugin Test

Now, let's test the plugin.

Allocate a host:

(
export ENDPOINT=$(cd deploy_infra && cfy local outputs | jq '.ServiceEndpoint.ip' | sed s/\"//g) &&
cd plugin_test &&
cfy local init --install-plugins -p ../plugin-demo-blueprint.yaml -i hostpool_svc_endpoint=http://${ENDPOINT}:8080 && cfy local execute -w install --task-retries=9 --task-retry-interval=9
)

And to deallocate a host:

(cd plugin_test && cfy local execute -w uninstall --task-retries=9 --task-retry-interval=9)

Uninstall

(cd deploy_infra && cfy local execute -w uninstall --task-retries=9 --task-retry-interval=9)