Multi-cloud Node.js Example
This example demonstrates deploying Node.js web server and application on a chosen infrastructure.
The infrastructure can be one of the following:
- Amazon Web Services (AWS)
- AWS - Terraform
- AWS - Cloudformation
- Google Cloud Platform (GCP)
- Azure
- Azure - ARM
- Openstack
The infrastructure deployment consists of:
- VM
- network
- all of the essential peripherals in each infrastructure (IP address, NIC, etc…).
the second deployment consists of the chosen infrastructure, Node.js, Node.js http-server module, and a sample page.
Prerequisites
This example expects the following prerequisites:
- A cloudify manager setup ready. This can be either a Cloudify Hosted service trial account, a Cloudify Premium Manager, or a Cloudify Community Manager.
- Access to the cloud infrastructure you select is required to demonstrate this example.
CLI or Management Console?
Cloudify allows for multiple user interfaces. Some users find the Cloudify Management Console (web based UI) more intuitive while others prefer the Cloudify CLI (Command Line Interface). This tutorial and all following ones will describe both methods.
Community version - Some of the options described in the guide are not available in the community version management console (web UI). An example would be setting up secrets. You can still perform all of the functionality using the Cloudify CLI.
Cloudify Management Console
This section explains how to run the above described steps using the Cloudify Management Console. The Cloudify Management Console and Cloudify CLI can be used interchangeably for all Cloudify activities.
Create Secrets
To connect to an infrastructure, a set of credentials are required. Cloudify recommends storing such sensitive information in a Cloudify secret. Secrets are kept encrypted in a secure way and used in run-time by the system. Learn more about Cloudify secrets here.
In this example, an infrastructure provider is selected during blueprint install. To ensure the correct secrets are created, use the following table to import the secrets for the provider selected.
Infrastructure Provider | Example |
---|---|
AWS | Infrastructure provisioning basics |
AWS (Terraform) | Infrastructure provisioning basics |
AWS (Cloudformation) | Infrastructure provisioning basics |
GCP | Infrastructure provisioning basics |
Azure | Infrastructure provisioning basics |
Azure (ARM) | Infrastructure provisioning basics |
OpenStack | Infrastructure provisioning basics |
To store the access keys as secrets in the Cloudify manager, login to the Cloudify Management Console and select the System Resources page. Scroll to the Secret Store Management widget and use the Create button to add the following new secrets:
Upload Plugins
Plugins are Cloudify’s extendable interfaces to services, cloud providers and automation tools. I.e., connecting to AWS requires the AWS plugin.
To upload the required plugins to your manager, select the Cloudify Catalog page, scroll to the Plugins Catalog widget and select the plugins you wish to upload.
For this example, upload the following plugins:
- Utilities
- Fabric
- The plugin that matches the infrastructure you’re going to use
Upload Blueprint
A Cloudify blueprint is a general purpose model for describing systems, services or any orchestrated object topology. Blueprints are represented as descriptive code (yaml based files) and typically stored and managed as part of the source repository. The infrastructure blueprint is available here.
The flow required to setup a service consists of:
- Upload the blueprint describing the service to the Cloudify Manager.
- Create a deployment from the uploaded blueprint. This generates a model of the service topology in the Cloudify database and provides the “context” needed for running workflows.
- Run the install workflow for the created deployment to apply the model to the infrastructure.
Let’s run these one by one.
To upload a blueprint to the Cloudify manager, select the Local Blueprints page, and use the Upload button.
- Blueprint package: link
- Blueprint name: getting-started
- Blueprint YAML file: mc-nodejs.yaml
Deploy & Install
Once the blueprint is uploaded, it will be displayed in the Blueprints widget. to deploy the blueprint click the Create deployment button next to the blueprint you wish to deploy. Specify a deployment name, update any inputs (such as the infrastructure region), and click Deploy & Install. Changing inputs is completely optional and the defaults are safe to use.
You will be directed to the Deployment page and will be able to track the progress of the execution.
The deployment you have created should be displayed in the deployments list in the Deployments page.
Validate
In this example we have setup a simple infrastructure. A virtual instance (VM) was created in the region specified in the Deployment inputs alongside a new network and various other resources.
- Go to your infrastructure (AWS, Azure, etc…) console and see the new instance and other resources that were created.
- Examine the Deployment page in the Cloudify Management Console for more information about your deployed nodes, topology, and view the installation logs.
To login to your new instance, you can look at the Deployment Outputs/Capabilities widget on the Deployment screen to find your instance public IP, SSH username, and SSH private key.
Teardown
To remove the deployment and destroy the orchestrated infrastructure resources, run the Uninstall workflow by clicking the Execute workflow menu next to the deployment, expanding Default workflows, and selecting Uninstall.
Cloudify CLI
Create Secrets
To enable Cloudify to connect to infrastructure, credentials are required. Cloudify recommends storing such sensitive information as a Cloudify secret. Secrets are encrypted in a secure way and used during run-time by the system. Learn more about Cloudify secrets here.
In this example, an infrastructure provider is selected during blueprint install. To ensure the correct secrets are created, use the following table to import the secrets for the provider selected.
Infrastructure Provider | Example |
---|---|
AWS | Infrastructure provisioning basics |
AWS (Terraform) | Infrastructure provisioning basics |
AWS (Cloudformation) | Infrastructure provisioning basics |
GCP | Infrastructure provisioning basics |
Azure | Infrastructure provisioning basics |
Azure (ARM) | Infrastructure provisioning basics |
OpenStack | Infrastructure provisioning basics |
Upload Plugins
Plugins are Cloudify’s extendable interfaces to services, cloud providers, and automation tools. For example, connecting to AWS requires the AWS plugin. You may upload specific plugins or, for simplicity, upload the plugin bundle containing all of the basic, pre-packaged, plugins.
To upload the default plugins bundle (this may take a few minutes depending on your internet speed):
cfy plugins bundle-upload
Tip: Read more about Cloudify plugins and writing your own plugins.
Upload Blueprint and Deploy
A Cloudify blueprint is a general purpose model for describing systems, services or any orchestrated object topology. Blueprints are represented as descriptive code (YAML-based files) and are typically stored and managed as part of the source code repository.
The infrastructure blueprint is available here.
Uploading a blueprint to Cloudify can be done by direct upload or by providing the link in the source code repository. The flow to do that is:
- Upload the blueprint.
- Create a deployment from the uploaded blueprint. This generates a model of the service topology in the Cloudify database and provides the “context” needed for running workflows.
- Run the install workflow for the created deployment to apply the model to the infrastructure.
In order to perform this flow as a single unit, we will use the install command.
cfy install https://github.com/cloudify-community/blueprint-examples/releases/download/latest/getting-started.zip -n mc-nodejs.yaml -i infra_name=<YOUR_INFRASTRUCTURE_NAME>
Replace YOUR_INFRASTRUCTURE_NAME
with any of the following -
- openstack
- azure
- azure-arm
- aws
- aws-terraform
- aws-cloudformation
- gcp
- ansible
Validate
In this example we have setup a simple infrastructure. A virtual instance (VM) was created in the region specified in the Deployment inputs alongside a new network and various other resources.
- Go to your infrastructure console and see the new instance and other resources that were created.
You can easily get a list of all deployed nodes by running:
Listing nodes for deployment getting-started.mc-nodejs... Nodes: +----------------+---------------------------+---------------------------+---------+----------------------------------+------------+----------------+---------------------+-----------------------------+------------+ | id | deployment_id | blueprint_id | host_id | type | visibility | tenant_name | number_of_instances | planned_number_of_instances | created_by | +----------------+---------------------------+---------------------------+---------+----------------------------------+------------+----------------+---------------------+-----------------------------+------------+ | infrastructure | getting-started.mc-nodejs | getting-started.mc-nodejs | | cloudify.nodes.Component | tenant | default_tenant | 1 | 1 | admin | | sample_app | getting-started.mc-nodejs | getting-started.mc-nodejs | | cloudify.nodes.SoftwareComponent | tenant | default_tenant | 1 | 1 | admin | | http_server | getting-started.mc-nodejs | getting-started.mc-nodejs | | cloudify.nodes.ApplicationServer | tenant | default_tenant | 1 | 1 | admin | | nodejs | getting-started.mc-nodejs | getting-started.mc-nodejs | | cloudify.nodes.ApplicationServer | tenant | default_tenant | 1 | 1 | admin | +----------------+---------------------------+---------------------------+---------+----------------------------------+------------+----------------+---------------------+-----------------------------+------------+ Showing 4 of 4 nodes
Tip: To check out some more commands to use with the Cloudify Management Console, run cfy --help
To get the Outputs of our deployment run:
cfy deployment outputs getting-started.mc-nodejs
The returned output would look like:
Retrieving outputs for deployment getting-started.mc-nodejs...
- "admin_url":
Description: Administration console URL
Value: http://40.79.42.39:8080
Copy and paste the URL Value into your browser, you should see a simple web page.
An even easier way to review your deployment is through the Cloudify Management Console.
Login to the console and browse to the Deployments page.
Select the deployment (getting-started.mc-nodejs
) and explore the topology, inputs, outputs, nodes, and logs.
This is also a good time to examine the Cloudify blueprint used in the example. The blueprint can be examined in the Cloudify Management Console, however in this case we will go to the Cloudify examples repository in Github and examine it there: mc-nodejs.yaml
Teardown
To remove the deployment and delete all resources, simply run the uninstall command:
cfy uninstall getting-started.mc-nodejs