Deploy your first cloud application using automation¶
This section aims to help you build your first cloud application and onboard it to a MOSK cloud. It will guide you through the process of deploying and managing a sample application using automation, and showcase the powerful capabilities of OpenStack.
Sample application¶
The sample application offered by Mirantis is a typical web-based application consisting of a front end that provides a RESTful API situated behind the cloud load balancer (OpenStack Octavia) and a backend database that stores data in the cloud block storage (OpenStack Cinder volumes).
You can extend the sample application to make use of advanced features offered by MOSK, for example:
An HTTPS-terminating load balancer that stores its certificate in the Key Manager service (OpenStack Barbican)
A public endpoint accessible by the domain name with the help of the DNS service (OpenStack Designate)
Deployment automation tools¶
The sample application intends to showcase how deployment automation can enable the DevOps engineers to streamline the process of installing, updating, and managing their workloads in the cloud providing an efficient and scalable approach to building and running cloud-based applications.
The sample application offers example templates for the most common tools that include:
OpenStack Heat, an OpenStack service used to orchestrate composite cloud applications with a declarative template format through the OpenStack-native REST API
Terraform, an Infrastructure-as-code tool from HashiCorp, designed to build, change, and version cloud and on-prem resources using a declarative configuration language
You can easily customize and extend the templates for similar workloads.
Note
The sample source code and automation templates reside in the OpenStack RefApp GitHub repository.
Environment
The sample cloud application deployment has been verified in the following environment:
OpenStack command-line client v5.8.1
Terraform v1.3.x
OpenStack Yoga
Ubuntu 18.04 LTS (Bionic Beaver) as guest operating system
Obtain the access credentials to the cloud¶
Log in to the cloud web UI (OpenStack Horizon).
Navigate to the project where you want to deploy the application.
Use the top-right user menu to download the
OpenStack RC File
to your local machine.
Note
As an example, you will be using your own user credential to deploy the sample application. However, in the future, Mirantis strongly recommends creating dedicated application credentials for your workloads.
Deploy sample application with OpenStack Heat¶
Prepare for the Heat stack creation:
Load the previously downloaded
openrc
file into the environment to configure the OpenStack client with the access credentials:source <YOUR_PROJECT>-openrc.sh
Verify that a Heat stack with the target name does not exist:
STACK_NAME=sampleapp openstack stack check $STACK_NAME
Generate an SSH keypair to access front-end and database instances:
cd <OPENSTACK_REFAPP>/heat-templates ssh-keygen -m PEM -N '' -C '' -f .openstack
Verify the default deployment configuration in the
top.yaml
template. Modify parameters as required. For example, you may want to change the image, flavor, or network parameters.Create the stack using the provided template with the public key generated above:
PUBLIC_KEY=$(<.openstack.pub) openstack stack create -t top.yaml --parameter "cluster_public_key=${PUBLIC_KEY}" $STACK_NAME
Verify that the Heat stack has been created successfully and the application instances are running:
openstack stack event list $STACK_NAME openstack stack resource list $STACK_NAME openstack stack show $STACK_NAME
Obtain the URL of application public endpoint:
openstack stack output show $STACK_NAME app_url
Deploy sample application with Terraform¶
Download and install the Terraform binary on your local machine, for example:
wget -O- https://releases.hashicorp.com/terraform/1.3.9/terraform_1.3.9_linux_amd64.zip | funzip > /usr/bin/terraform chmod +x /usr/bin/terraform
Generate an SSH keypair to be used to log in to the application instances:
cd <OPENSTACK_REFAPP>/terraform/templates ssh-keygen -m PEM -N '' -C '' -f .openstack
Load the previously downloaded
openrc
file into the environment to configure Terraform with the cloud access credentials:source <YOUR_PROJECT>-openrc.sh
Verify that all required Terraform providers are properly installed and configured:
terraform init
Generate a speculative execution plan that outlines the actions required to implement the current configuration and apply the Terraform state:
terraform plan terraform apply -auto-approve
Note
If
HTTPS_PROXY
is set, also setNO_PROXY
before running terraform plan:export NO_PROXY="it.just.works"
Obtain the URL of the application public endpoint:
terraform output app_url
Verify application functioning¶
Run the curl tool against the URL of the application public end point to make sure that all components of the application have been deployed correctly and it is responding to user requests:
$ curl http://<APP_URL>/
{"host": "host name of API instance that replied","app": "openstack-refapp"}
The sample application provides a RESTful API, which you can use for advanced database queries.
See also