A quick tutorial for getting started with Cloudify and deploying your first blueprint
Cloudify is a Cloud Application Orchestrator. It automates any process you need to perform with regard to your applications over any cloud. Cloudify provides:
In this tutorial you will start a Cloudify manager within a Vagrant box on your laptop, and install a sample Cloudify 3.0 blueprint on it.
Unlike a real cloud deployment, this example will install the application’s components on a Vagrant VM. If you’d like to install an
application(?) on an actual cloud, please refer to the deploying your first application on OpenStack guide.
The blueprint you’ll be deploying, describes a nodejs application that connects to a MongoDB database and presents a wine catalog. To learn more about blueprint syntax and elements please refer to the Blueprints Guide.
The Terminology Reference Page will help you understand some of the terms stated in this guide. For your convenience, links are supplied throughout the guide to point you to the right term definition in the terminology page.
We’ll need to have the following setup in your environment:
Notes for Windows users
bcdedit /set hypervisorlaunchtype offcommand (reboot is needed).
The first thing you’ll need to do is download the Vagrant box which contains the Cloudify manager and CLI and the Vagrantfile to run it.
First, download this Vagrantfile to your local directory. Then, run
vagrant box add http://gigaspaces-repository-eu.s3.amazonaws.com/org/cloudify3/3.0.0/nightly_6/cloudify_3.0.0_virtualbox.box --name=cloudify
which will add the vagrant box to your local machine.
Note that this downloads a full featured Ubuntu OS with Cloudify and its components installed so this may take some time to add.
After the box is added, run (from the same directory the Vagrantfile is in):
Once the cloudify box is up you can access the manager web console through your local browser by pointing the browser to http://220.127.116.11/.
To connect to the newly Up’d box, type:
after which Cloudify’s CLI will be at your disposal.
Now you’ll have to clone a sample blueprint repo. (Git is already supplied with the machine so there’s no need to install it.)
cd ~/simple/blueprints git clone https://github.com/cloudify-cosmo/cloudify-nodecellar-singlehost.git cd cloudify-nodecellar-singlehost/ git checkout tags/3.0
cloudify-nodecellar-singlehost directory you just cloned, you can see a blueprint file (named
blueprint.yaml) alongside other resources related to this blueprint.
To upload the blueprint run:
cd ~/simple cfy blueprints upload -b nodecellar1 blueprints/cloudify-nodecellar-singlehost/blueprint.yaml
-b flag is the unique name we’ve assigned to this blueprint on the Cloudify manager. Before creating a deployment though, let’s see what this blueprint looks like. Point your browser at the manager’s URL again and refresh the screen. You will see the nodecellar blueprint listed there.
In our case, we have the following nodes:
Next, we need to create a deployment. To do so, type the following command:
cfy deployments create -b nodecellar1 -d nodecellar1
We’ve now created a deployment named
nodecellar1 based on a blueprint with the same name. This deployment is not yet materialized, since we haven’t issued an installation command. If you click the “Deployments” icon in the left sidebar in the web UI, you will see that all nodes are labeled with 0/1, which means they’re pending creation.
cfy deployments execute -d nodecellar1 install
This will take a couple of minutes, during which the resources will be created and configured.
To track the progress of the installation, you can look at the events emitted to the terminal window. Each
event(?) is labeled with its time, the deployment name and the node in our topology that it relates to, e.g.
2014-07-21T15:37:31 CFY <nodecellar1> [mongod_vm_41765] Starting node
In the Web UI, you can checkout the Logs/Events page for an overview of all Logs and Events in a specific Manager. Alternatively, open up a specific deployment and a sidebar containing events and logs for the corresponding deployment will be shown.
To test the application, you will need to access it using its public IP address. Go to http://18.104.22.168:8080 to access it from your web browser. The marvelous nodecellar application should be up on your screen. Click the “Browse wines” button to verify that the application was installed suceesfully and can access the mongodb database to read the list of wines.
Uninstalling the deployment is just a matter of running another workflow, which will teardown all the resources provisionined by the
install workflow. To run the
uninstall(?) workflow, type the following command:
cfy deployments execute -d nodecellar1 uninstall
Similarly to the
install workflow, you can track the progress of the uninstall process in the CLI or the web UI using the events that are displayed in both. Once the workflow is completed, you can verify that the resources were indeed destroyed.
In a real cloud deployment, each and every resource provisioned by the deployment will be destroyed. In our case, there aren’t any external resources, only application related ones.
The next step is deleting the deployment. assuming the uninstallation went fine, all of the application resources should have been removed. However, the deployment itself still has record on the manager. For example, all of its static and runtime properties are still stored in the manager’s database. To clean up all the information related to the deployment on the manager, delete the deploymet as follows:
cfy deployments delete -d nodecellar1
Next, you can teardown the manager if you have no use for it. This can be done by issuing the following command:
cfy teardown -f --ignore-deployments
In a real cloud deployment, this will terminate the Manager VM and delete the resources associated with it. In our case, since the manager is installed on the same machine the CLI is installed on, it will not teardown the machine.
Once you’re done, you can exit the ssh session.
If you want to destroy the machine, run:
vagrant destroy -f
If you want to start the same machine again, just “Up” it. If you want to completely remove the box from your machine, run:
vagrant box remove cloudify