Bookmark this page

Launching a Cloud Application Stack

Objectives

After completing this section, you should be able to describe a 3-tier web application, as defined in the stack template used to launch the application.

The Orchestration Service

Orchestration automates provisioning of cloud resources, including virtual networks, storage, and servers. It gives domain operators an easy way to create and manage cloud resources in an orderly and predictable fashion. The Orchestration service (Heat) provides OpenStack with orchestration functionality. Orchestration facilitates service deployment by providing a unified interface that can parse text-based instructions. These templates specify the resources to spawn in the cloud, such as compute instances or volumes. The orchestration stack can be composed of a single template or multiple nested templates.

The orchestration service can also execute Heat Orchestration Template (HOT) files written in YAML.

When using either the Dashboard or command line to provision a stack using HOT files, the restful API's are used.

Figure 8.6: Orchestration flow chart

You can use multiple layers of stacks that build on top of each other and also create a nested stack, so you can have a base stack that has other definitions of templates listed inside of it. This is a way of creating reproducible and reliable deployments from applications by using everything from a template instead of trying to go in and do it manually.

Nested stacks can replace flavor, networking name, and hard-coded resources in the template directly. The templating engine evalutes the template, replacing options based on provided parameters.

The Heat engine can also validate a template for a stack before deploying it, and this will verify things like syntax or semantics, and ensure there are no circular dependencies.

Use the --dry-run option as a sanity check, to go through the process and not make changes, but review if everything that gets output will be created correctly.

The Orchestration service can automatically scale-out infrastructure or resources in response to specific situations, such as alarm, threshold, application signal, or the telemetry service.

Deploying 3-tier Web Application Architecture

The deployment of the 3-tier web application using HOT files can be done through the OpenStack Dashboard and command line. Each case is shown below.

Managing Stacks using the OpenStack CLI

To create a stack from a template, use the openstack stack create command. The --parameter option is used to pass various input parameters required by the template. The option can be used multiple times to pass multiple launch parameters. The --template option specifies the path of the template file.

[user@demo ~(user-demo)]$ openstack stack create \
> --parameter "instance_name=first-instance" \
> --template demo-template.yaml \
> demo-stack
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | b1661275-25e2-49f1-b253-c4865168c3b1 |
| stack_name          | demo-stack                           |
| description         | My HOT template.                     |
|                     |                                      |
| creation_time       | 2020-08-23T04:52:05Z                 |
| updated_time        | None                                 |
| stack_status        | CREATE_IN_PROGRESS                   |
| stack_status_reason | Stack CREATE started                 |
+---------------------+--------------------------------------+

The openstack stack create --dry-run command validates a template file without deploying a stack. The --enable-rollback option enables the rollback of created resources, in case the stack fails to create all the resources defined in the template file.

To explore the state of the stack and to list the stacks accessible to the user, use the openstack stack list -f json command.

[user@demo ~(user-demo)]$ openstack stack list -f json
[
  {
    "ID": "b1661275webstack-25e2-49f1-b253-c4865168c3b1",
    "Stack Name": "demo-stack",
    "Stack Status": "CREATE_COMPLETE",
    "Creation Time": "2020-08-23T04:52:05Z",
    "Updated Time": null
  }
]

To view information about a stack, use the openstack stack show STACK-NAME command. The stack deploys various resources. To list these resources and their status, run the openstack stack resource list STACK-NAME command.

[user@demo ~(user-demo)]$ openstack stack resource list demo-stack -f json
[
  {
    "resource_name": "server_port",
    "physical_resource_id": "3d615dce-4c52-4496-9109-abd2e96e7938",
    "resource_type": "OS::Neutron::Port",
    "resource_status": "CREATE_COMPLETE",
    "updated_time": "2020-08-23T04:52:05Z"
   },
   {
    "resource_name": "server",
    "physical_resource_id": "3dd96b3d-0a02-4d8d-84cb-89d309530fbf",
    "resource_type": "OS::Nova::Server",
    "resource_status": "CREATE_COMPLETE",
    "updated_time": "2020-08-23T04:52:05Z"
   },
   {
    "resource_name": "server_floating_ip",
    "physical_resource_id": "9547dd01-a441-47ad-87b0-8b89f597de6f",
    "resource_type": "OS::Neutron::FloatingIP",
    "resource_status": "CREATE_COMPLETE",
    "updated_time": "2020-08-23T04:52:05Z"
   },
   {
    "resource_name": "server_security_group",
    "physical_resource_id": "9bded7df-0ae8-43a7-aed5-c47e4a9c7c01",
    "resource_type": "OS::Neutron::SecurityGroup",
    "resource_status": "CREATE_COMPLETE",
    "updated_time": "2020-08-23T04:52:05Z"
   }
]

To view details of a particular resource created by the stack, run openstack stack resource show STACK-NAME RESOURCE-NAME.

[user@demo ~(user-demo)]$ openstack stack resource show demo-stack server

Events are generated while deploying the stack and during its life cycle. To list the events generated by the stack, use the openstack stack event list STACK-NAME command.

[user@demo ~(user-demo)]$ openstack stack event list demo-stack
020-08-23 04:52:05Z [demo-stack]: CREATE_IN_PROGRESS  Stack CREATE started
2020-08-23 04:52:06Z [demo-stack.server_security_group]: CREATE_IN_PROGRESS  state changed
2020-08-23 04:52:07Z [demo-stack.server_security_group]: CREATE_COMPLETE  state changed
2020-08-23 04:52:07Z [demo-stack.server_port]: CREATE_IN_PROGRESS  state changed
2020-08-23 04:52:08Z [demo-stack.server_port]: CREATE_COMPLETE  state changed
2020-08-23 04:52:08Z [demo-stack.server_floating_ip]: CREATE_IN_PROGRESS  state changed
2020-08-23 04:52:08Z [demo-stack.server]: CREATE_IN_PROGRESS  state changed
2020-08-23 04:52:12Z [demo-stack.server_floating_ip]: CREATE_COMPLETE  state changed
2020-08-23 04:52:33Z [demo-stack.server]: CREATE_COMPLETE  state changed
2020-08-23 04:52:33Z [demo-stack]: CREATE_COMPLETE  Stack CREATE completed successfully

The CREATE_COMPLETE state indicates that the resource specified in the stack is created. The CREATE_IN_PROGRESS state indicates that the resource creation is still in progress. The CREATE_FAILED state indicates that the provision of the resource failed.

Detailed information about an event can be viewed using the openstack stack event show STACK-NAME RESOURCE-NAME EVENT-ID command.

Note

Because event IDs are not displayed by openstack stack event list, use the heat event-list STACK-NAME command to view the event ID.

List the event IDs using the heat event-list command.

[user@demo ~(user-demo)]$ heat event-list demo-stack
+-----------------------+--------+------------------------+--------------------+
| resource_name         | id     | resource_status_reason | resource_status    |
+-----------------------+--------+------------------------+--------------------+
| demo-stack            | a(...) | Stack CREATE started   | CREATE_IN_PROGRESS |
| server_security_group | 7(...) | state changed          | CREATE_IN_PROGRESS |
| server_security_group | 2(...) | state changed          | CREATE_COMPLETE    |
| server_port           | a(...) | state changed          | CREATE_IN_PROGRESS |
| server_port           | 0(...) | state changed          | CREATE_COMPLETE    |
| server_floating_ip    | c(...) | state changed          | CREATE_IN_PROGRESS |
| server                | 7(...) | state changed          | CREATE_IN_PROGRESS |
| server_floating_ip    | 4(...) | state changed          | CREATE_COMPLETE    |
| server                | e(...) | state changed          | CREATE_COMPLETE    |
| demo-stack            | a(...) | Stack CREATE completed | CREATE_COMPLETE    |
|                       |        | successfully           |                    |
+-----------------------+--------+------------------------+--------------------+

List the detailed information of a particular event using the openstack stack event show command. Use the event ID returned by the heat event-list command.

[user@demo ~(user-demo)]$ openstack stack event show demo-stack server e7327efa-86a5-4f13-9c9f-ce51ac8ed78e
+------------------------+------------------------------------------------------+
| Field                  | Value                                                |
+------------------------+------------------------------------------------------+
...output omitted...
| resource_properties    | {                                                    |
| resource_type          | OS::Nova::Server                                     |
|                        |   "key_name": "example-keypair",                     |
|                        |   "image": "rhel8-web",                              |
|                        |   "flavor": "default",                               |
|                        |   "networks": [                                      |
|                        |     {                                                |
|                        |       "port": "3d615dce-4c52-4496-9109-abd2e96e7938" |
|                        |     }                                                |
|                        |   ],                                                 |
|                        |   "user_data":                                       |
|                        |   "#!/bin/bash\n                                     |
|                        |   echo 'cloud-init works' > /root/test.txt\n"        |
|                        | }                                                    |
+------------------------+------------------------------------------------------+

Updating a deployed stack only updates the resources that are modified in the template file. Use the openstack stack update command to update an existing stack.

While updating a stack, some resources are updated by changing their properties. This type of change does not require any downtime. However, there are some resources that are replaced with new resources when the stack is updated. Such an update should be avoided if possible because it requires downtime.

[user@demo ~(user-demo)]$ openstack stack update \
> --parameter "instance_name=demo-server1" \
> --template demo-template.yaml \
> demo-stack
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | b1661275-25e2-49f1-b253-c4865168c3b1 |
| stack_name          | demo-stack                           |
| description         | My HOT template.                     |
|                     |                                      |
| creation_time       | 2020-08-23T04:52:05Z                 |
| updated_time        | 2020-08-24T11:26:39Z                 |
| stack_status        | UPDATE_IN_PROGRESS                   |
| stack_status_reason | Stack UPDATE started                 |
+---------------------+--------------------------------------+

Domain operators can delete a stack using openstack stack delete STACK-NAME. All resources associated with the stack are also deleted. The --yes option can be used to skip the prompt when deleting the stack.

[user@demo ~(user-demo)]$ openstack stack delete demo-stack
Are you sure you want to delete this stack(s) [y/N]? y

Creating a 3-tier Web Application from the Dashboard

The following steps describe the process for creating OpenStack resources using a Heat template from the Dashboard.

  1. Log in to the Dashboard and from top right Project menu select the project you wish to deploy to.

  2. Navigate to OrchestrationStacks, and then click Launch Stack.

  3. Choose the appropriate template source and click Next.

  4. Enter the name of the stack in the Stack Name field.

  5. Click Launch.

  6. Select the stack name link to view more details about the stack.

    The Topology tab shows various resources that the stack creates. Hovering the mouse over the resource icons in the Topology tab shows the resource type and the resource name.

    Click the Overview tab to display the stack parameters, stack status, stack output, and launch parameters.

    The Resources tab shows the resources created by the stack. Click a resource name or resource ID to display more details about the resource.

    The Events tab shows events that occur during the deployment of the stack, and after it has been deployed.

    The Template tab shows the Heat template used to deploy the stack.

 

References

Heat Orchestration Template (HOT) Guide

For more information, refer to the Understanding Heat Templates chapter in the Red Hat OpenStack Platform 16 Advanced Overcloud Customization at https://access.redhat.com/documentation/en-us/red_hat_openstack_platform/16.0/html-single/advanced_overcloud_customization/index#sect-Understanding_Heat_Templates

Revision: cl110-16.1-4c76154