What is OpenStack Orchestration (Heat): What is Heat and Installation of the Heat Client?, Hostripples Web Hosting

What is OpenStack Orchestration (Heat): What is Heat and Installation of the Heat Client?

In continuation of our previous article on OpenStack Dashboard, today we are going to discuss a new component of the OpenStack, which is: “OpenStack Orchestration (Heat)”.

First, we will discuss what Heat is and then we will move on to the installation of its client, an example of creating a simple template and launching it and then we will discuss advanced template using parameters and outputs.

Without wasting time let’s start with what Heat is:

But before starting the discussion, the prerequisite for understanding the Heat component of OpenStack, it is recommended that you should install OpenStack on your system so that it will be easy for you to understand it.

OpenStack Orchestration Program Heat:

In the OpenStack Orchestration program, Heat is considered as the major venture because it permits the users to report the installation of the complicated cloud applications in Templates, which are just text files. After that, the Heat engine analyzes and accomplishes these templates.

The OpenStack Heat component was brought into as an equivalent to a service in AWS called the cloud formation service. The AWS templates are accepted by it and then it gives a suitable API. But in the latest releases of OpenStack, it has started to expand without the cloud formation, which gives a much better template style i.e. Heat Orchestration Template or also called as HOT and it also provides additional features which are not at all supported by the competitors.

Installation of the Heat Client:

It is seen that with the majority of the OpenStack services, front line access to the Heat is possible by using the REST API. Most of the times, it is more suitable to work with the client.

The two official Heat clients are:

  1. A stand-alone command line client and
  2. A web-based client including Horizon which is the OpenStack dashboard project.

In today’s article, we are going to use the command line client. And I would like to recommend you to install this client on your computer. And we are going to discuss the web-based client in our next article.

By using following commands, you can build a Python virtual environment and then you can install the command line Heat client in this environment, provided that you are using bash or any other similar kind of command prompt.

Note:

We assume that before running the following commands you have already installed Python and virtualenv on your computer system.

$ virtualenv venv

$ source venv/bin/activate

(venv) $ pip install python-heatclient

The commands are little bit different, if any one of you is working on windows:

$ virtualenv venv

$ venv\Scripts\activate

(venv) $ pip install python-heatclient

For verifying that, whether heat was successfully installed or not, you need to run just the client excluding arguments for viewing the help message:

 (venv) $ heat

usage: heat [–version] [-d] [-v] [-k] [–os-cacert <ca-certificate>]

            [–cert-file CERT_FILE] [–key-file KEY_FILE] [–ca-file CA_FILE]

            [–api-timeout API_TIMEOUT] [–os-username OS_USERNAME]

            [–os-password OS_PASSWORD] [–os-tenant-id OS_TENANT_ID]

            [–os-tenant-name OS_TENANT_NAME] [–os-auth-url OS_AUTH_URL]

            [–os-region-name OS_REGION_NAME] [–os-auth-token OS_AUTH_TOKEN]

            [–os-no-client-auth] [–heat-url HEAT_URL]

            [–heat-api-version HEAT_API_VERSION]

            [–os-service-type OS_SERVICE_TYPE]

            [–os-endpoint-type OS_ENDPOINT_TYPE] [–include-password]

            <subcommand> …

Now we would like to suggest you import your OPENRC file with your credentials into the Python virtual environment, therefore it is not required to include those account credentials as command line arguments. Because it is important to note that, similar to another OpenStack command line clients, the heat client also require access to the credentials of your account and these are normally stored in OPENRC file.

A simple Heat Orchestration Template:

As we have discussed what heat is and how to install a Heat client, many of you must be excited to watch how OpenStack Orchestration Heat works, so let’s check it out.

Blow is an example of the simple HOT template:

In this example, you can see that these templates are written as organized YAML text files, which are widely used for configuration files. YAML stands for “YAML Ain’t Markup Language”.

heat_template_version: 2013-05-23

description: Simple template to deploy a single compute instance

resources:

   my_instance:

     type: OS::Nova::Server

        properties:

           image: cirros-0.3.3-x86_64

            flavor: m1.small

             key_name: my_key

           networks:

           – network: private-net

Above example contains three top-level sections:

  1. heat_template_version
  2. description
  3. resources

Here is the explanation of each of these three top-level sections:

  • heat_template_version:

This is a compulsory section which is used for specifying the version of the template which is being used. In most of the templates, you will see 2013-05-23 as a version i.e. the first release. The newer version is 2014-10-16 and it was launched along with the Juno release which includes very slight changes as well as slight additions.

  • description:

This is the second top-level section which is an optional section and the use of this section is to give an explanation of what the template does.

  • resources:

This is the third top-level section and in a template, it is the most important section because in this section all the different components are defined. In the above template, the resource is referred to my_instance, which is declared with OS:: Nova:: server as the type. And this is a type of a compute instance of Nova. The subsection is properties which recognize an image, public key, private network and flavor which are used for the illustration.

Now we are going to launch this template! For that first you need to Copy and paste the above text in your preferred text editor, then modify the image, flavor, public key and private network names so that they match up to your OpenStack installation. Once it is done, save the file as heat_11a.yaml.

Important Note:

The private network required to be described as id rather than a name, if you are working with OpenStack Havana or Icehouse.

Use nova net-list or neutron net-list commands if you want to find the id of your network. Both the id and name are supported in Juno release.

Use the following command for creating a stack using template, once the template is on the disk:

 (venv) $ heat stack-create my_first_stack -f heat_11a.yaml

+——–+—————-+——————–+———————-+

| id     | stack_name     | stack_status       | creation_time        |

+——–+—————-+——————–+———————-+

| …    | my_first_stack | CREATE_IN_PROGRESS | 2014-11-05T18:10:40Z |

+——–+—————-+——————–+———————-+

Once this command is executed, Heat begins its background job which initiates the resources that are declared in the above template. And as mentioned earlier, there is only one resource i.e. nova-compute instance.

Use the following command, if you want to check the status of this job:

 (venv) $ heat stack-show my_first_stack

This command will output the complete information for this particular stack, containing its status, and that will be CREATE_COMPLETE or it could be CREATE_FAILED, in case if there was an error.

Earlier we saw an example of a simple template, now let’s look at an advanced version of it i.e. Template with parameters and its outputs:

heat_template_version: 2013-05-23

description: Simple template to deploy a single compute instance

parameters:

  image:

    type: string

    label: Image name or ID

    description: Image to be used for compute instance

    default: cirros-0.3.3-x86_64

  flavor:

    type: string

    label: Flavor

    description: Type of instance (flavor) to be used

    default: m1.small

  key:

    type: string

    label: Key name

    description: Name of key-pair to be used for compute instance

    default: my_key

  private_network:

    type: string

    label: Private network name or ID

    description: Network to attach instance to.

    default: private-net

resources:

  my_instance:

    type: OS::Nova::Server

    properties:

      image: { get_param: image }

      flavor: { get_param: flavor }

      key_name: { get_param: key }

      networks:

        – network: { get_param: private_network }

outputs:

  instance_ip:

    description: IP address of the instance

    value: { get_attr: [my_instance, first_address] }

In the above-advanced version of the template two top-level sections are being added, those are:

  1. parameters
  2. outputs

Here is the information about these two additional top level sections:

  1. parameters:

This section is used for declaring a list of inputs which are required to be given by the user.

  • outputs:

This section explains which attributes of the stack are required to be exported once it is installed.

A template can be turned into generic with the help of parameters section. Every parameter is assigned a name, a type and arbitrarily a default value and a description.

For inserting parameter values in the properties of resources, the get_param function is used. On the other side, the get_attr function is used in the outputs section for extracting required attributes related to the resources which are incorporated in the stack.

For executing this template, save it as heat_11b.yaml and as shown before launch it.

Note:

If your system is not similar to our system, then there is a possibility of receiving an error because the parameter defaults which we have defined may not likely to match with your OpenStack installation. But these settings are parameters now; still, you can mention the required values for your Python environment in the command: stack-create instead of editing the template file.

To try this new template, save it as file heat_11b.yaml and launch it as shown before. Unless your system is identical to mine, you are probably going to get an error, because the parameter defaults that I defined will likely not match your OpenStack installation. However, since these settings are now parameters, you can specify appropriate values for your environment in the stack-create command without having to edit the template file.

Summary:

In today’s article, we discussed what is Heat, how to create and launch a basic Heat template and we also discussed generically how to code the templates with the help of parameters and outputs.

I hope you find this article helpful! And thank you for reading this article. Please do not forget to leave a comment in the comment section below. I hope to see you soon!

People also read:


What is OpenStack Orchestration (Heat): What is Heat and Installation of the Heat Client?, Hostripples Web Hosting
Vishwajit Kale
Vishwajit Kale blazed onto the digital marketing scene back in 2015 and is the digital marketing strategist of Hostripples, a company that aims to provide affordable web hosting solutions. Vishwajit is experienced in digital and content marketing along with SEO. He's fond of writing technology blogs, traveling and reading.