Cloud Powering DH Research

Heat Orchestration Templates (HOT)

Overview

Teaching: 150 min
Exercises: 0 min
Questions
  • What do HOT templates do?

  • Can I use HOT templates with cloudInit scripts?

Objectives
  • Create a HOT template

In this episode we will learn how to perform automated cloud environment orchestration. Basically, by the time we’re done this episode, we’ll see that all the work that we performed during the first two days of the course can actually be accomplished in under 5 minutes by simply executing an OpenStack Heat template.

Heat is an OpenStack orchestration engine that is used to build entire cloud applications by parsing a declarative template in the form of a text file which is treated as code. These text files are referred to as HOT (Heat Orchestration Templates) and they are most commonly saved as human-readable YAML files. In short, they provide us with a method of automating the creation of all cloud components, including key pairs, security groups, security rules, volumes, networks, and virtual machine instances. One key advantage of using Heat is reproducibility. That is to say, in a disaster recovery situation where we would be required to recreate a previous cloud environment, we’d simply execute our template (which is basically an exact recording of the original environment) instead of manually clicking through various web GUI interfaces and potentially guessing at all the settings for our original configuration.

It should be noted that Heat is considered to be a fairly advanced topic and might easily have its own dedicated course in order to cover all of its elements in depth. However, for the sake of this course, in order to get you started, we will introduce some basic information, illustrate some useful examples which you can execute yourself, and provide additional references that you can explore on your own, should you decide to increase your orchestration knowledge and skills.

Terminology

There are 5 basic components that make up OpenStack Heat. They are as follows:

Heat Template Components

As previously mentioned, a Heat Template is most commonly a YAML file that contains the following document sections:

parameters:
  parameter_name:
    type: string | number | json | comma_delimited_list | boolean
    label: human-readable name of the parameter
    description: description of the parameter
    default: default value for parameter
    hidden: true | false
    constraints:
      - parameter constraint 1
    immutable: true | false

Supported parameter types include: number, comma_delimited_list, json and boolean. Default values are used when a users don’t specify their own values during deployment. You can declare parameters to be hidden, if you require that certain information should not be revealed upon request (such as passwords, etc). Constraints are rules that are validated by the OpenStack Heat engine during deployment. These rules might include valid instance types, images, number ranges, string length, string pattern, etc. If a specified parameter value violates a constraint, then the stack creation will fail. Finally, you can define whether or not you can later revise parameters by specifying the immutable field.

resources:
  resource_id:
    type: resource type
    properties:
      property_name_1: property value 1
      ...
    metadata:
      <resource specific metadata>
    depends_on: resource ID / list of resource IDs
    update_policy: dictionary of update policies
    deletion_policy: deletion policy
    external_id: external resource ID
    condition: condition name, expression, or boolean

The most important field is resource type. This is a required field and it specified what kind of cloud entity that will be deployed. Really, the most effective way to explain the resource section is to create, execute, and then deconstruct a few basic examples - which we will do in subsequent sections. In the meantime, you can find out more about resource types by using the Web GUI interface, clicking on Orchestration and then Resource Types in the menu.

Web GUI Orchestration Menu

Creating Your First HOT

To review the only required sections are: version, description, and resources. But it’s import to illustrate all 5 sections in order to better understand how Heat works. The example listed below is a very basic template that creates and launches a simple virtual machine instance.

heat_template_version: 2015-04-30


description: Simple HOT that deploys a virtual machine instance


parameters:
  key_name:
    type: string
    label: Key Pair Name
    description: Name of the key-pair used to log into the VM
    default: yoga3pro

  image_id:
    type: string
    label: Image ID
    description: Image used to deploy the VM
    default: Ubuntu-16.04-Xenial-x64-2017-03

  flavor:
    type: string
    label: Instance Type
    description: Instance type used to deploy the VM
    default: p2-3gb


resources:
  heat_vm:
    type: OS::Nova::Server
    properties:
      key_name: { get_param: key_name }
      image: { get_param: image_id }
      flavor: { get_param: flavor }


outputs:
  instance_ip:
    description: IP Address of the deployed VM
    value: { get_attr: [heat_vm, first_address] }

So, in a nutshell, here’s what’s happening:

Executing Your First Stack

Now that I have written my first template, I need to figure out how to execute it. The easiest method is to launch a stack using the Web Gui interface. You should already know how to log into the Web interface for Arbutus. Once there, select Orchestration and then click Stacks in the main menu. (See figure from previous section.)

NOTE from here to below is rough draft….

In the Stacks window, click Launch Stack.

[figure]

In the Select Template window ensure the following:

Then click Next

[figure]

In the Launch Stack window, provide a name for this stack, enter the password for your Arbutus account, and then review the default values for Instance Type, Image ID, and Key Pair Name. If you are satisfied click Launch.

[figure]

Finish this when I get home…

Still need an outputs screen shot

Deleting Your First Stack

Illustrating and Executing and Example WordPress HOT

Where to Find Additional Heat Information

Key Points