Home / Openstack / Openstack – Configure Orchestration Module (HEAT) – Part 17

Openstack – Configure Orchestration Module (HEAT) – Part 17

HEAT is Openstack’s orchestration program. It uses the template to create and manage openstack cloud resources. These templates normally called as HOT (HEAT orchestration  template). The templates will help to you to provision bunch of instances, floating IPs, volumes, security groups and users  in quick time. A Heat template describes the infrastructure for a cloud application in a text file in human  readable format along with version control. It also provides advanced functionality, such as instance high availability, instance auto-scaling, and nested stacks. This enables OpenStack core projects to receive a larger user base. Templates are defined  in YAML (Yet Another Markup Language) language.

In this article ,we will see that how to install and configure HEAT orchestration module .

 

Orchestration module Components:

  • heat –  command-line client
  • heat-api
  • heat-api-cfn
  • heat-engine

 

 Install and configure HEAT Orchestration :

1.Login to the controller node.

2. Create the heat database and grant the permission.

root@OSCTRL-UA:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 942
Server version: 5.5.44-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE heat;
Query OK, 1 row affected (0.02 sec)

mysql> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'localhost' IDENTIFIED BY 'heatdb123';
Query OK, 0 rows affected (0.07 sec)

mysql> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'%'  IDENTIFIED BY 'heatdb123';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
root@OSCTRL-UA:~#

 

3. Source the admin credentials for CLI access.

root@OSCTRL-UA:~# cat admin.rc
export OS_USERNAME=admin
export OS_PASSWORD=admin123
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://OSCTRL-UA:35357/v2.0
root@OSCTRL-UA:~# source admin.rc
root@OSCTRL-UA:~#

 

4. Create the keystone user account.

root@OSCTRL-UA:~# keystone user-create --name heat --pass heat123
+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |                                  |
| enabled  |               True               |
|    id    | f9e9583e6c69441cb80d556cd8b4a4da |
|   name   |               heat               |
| username |               heat               |
+----------+----------------------------------+
root@OSCTRL-UA:~#

 

5. Add the admin role for heat user.

root@OSCTRL-UA:~# keystone user-role-add --user heat --tenant service --role admin
root@OSCTRL-UA:~#

 

6.Create the heat_stack_owner role and add the tenant to it. We must add the heat_stack_owner role to users that manage the stacks.

root@OSCTRL-UA:~# keystone role-create --name heat_stack_owner
+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|    id    | 26d2886594944773abfea2e9e899c731 |
|   name   |         heat_stack_owner         |
+----------+----------------------------------+
root@OSCTRL-UA:~# keystone user-role-add --user lingesh --tenant lingesh --role heat_stack_owner
root@OSCTRL-UA:~#

 

7. The Orchestration service automatically assigns the heat_stack_user role to users that it creates during stack deployment. Create the heat_stack_user role.

root@OSCTRL-UA:~# keystone role-create --name heat_stack_user
+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|    id    | 5de39c7ec6ac4756bacf154a50fb02b8 |
|   name   |         heat_stack_user          |
+----------+----------------------------------+
root@OSCTRL-UA:~#

 

8.Create the heat and heat-cfn service entities using keystone command.

root@OSCTRL-UA:~# keystone service-create --name heat --type orchestration --description "Orchestration"
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |          Orchestration           |
|   enabled   |               True               |
|      id     | 59585bbaa4e04d2394df4a66e13993bf |
|     name    |               heat               |
|     type    |          orchestration           |
+-------------+----------------------------------+
root@OSCTRL-UA:~# keystone service-create --name heat-cfn --type cloudformation --description "Orchestration"
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |          Orchestration           |
|   enabled   |               True               |
|      id     | eefe2c1b881d431f83a5411ac7bfb20c |
|     name    |             heat-cfn             |
|     type    |          cloudformation          |
+-------------+----------------------------------+
root@OSCTRL-UA:~#

 

9.Create the Orchestration HEAT service API endpoints.

root@OSCTRL-UA:~# keystone endpoint-create --service-id $(keystone service-list | awk '/ orchestration / {print $2}') --publicurl http://OSCTRL-UA:8004/v1/%\(tenant_id\)s --internalurl http://OSCTRL-UA:8004/v1/%\(tenant_id\)s --adminurl http://OSCTRL-UA:8004/v1/%\(tenant_id\)s --region regionOne
+-------------+----------------------------------------+
|   Property  |                 Value                  |
+-------------+----------------------------------------+
|   adminurl  | http://OSCTRL-UA:8004/v1/%(tenant_id)s |
|      id     |    75117db38ebc4868a69fc6b7e14fc054    |
| internalurl | http://OSCTRL-UA:8004/v1/%(tenant_id)s |
|  publicurl  | http://OSCTRL-UA:8004/v1/%(tenant_id)s |
|    region   |               regionOne                |
|  service_id |    59585bbaa4e04d2394df4a66e13993bf    |
+-------------+----------------------------------------+
root@OSCTRL-UA:~# keystone endpoint-create --service-id $(keystone service-list | awk '/ cloudformation / {print $2}') --publicurl http://OSCTRL-UA:8000/v1 --internalurl http://OSCTRL-UA:8000/v1 --adminurl http://OSCTRL-UA:8000/v1 --region regionOne
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
|   adminurl  |     http://OSCTRL-UA:8000/v1     |
|      id     | 8a15369cd2e14aa199b4f60881169a1b |
| internalurl |     http://OSCTRL-UA:8000/v1     |
|  publicurl  |     http://OSCTRL-UA:8000/v1     |
|    region   |            regionOne             |
|  service_id | eefe2c1b881d431f83a5411ac7bfb20c |
+-------------+----------------------------------+
root@OSCTRL-UA:~#

 

10. Install Orchestration components .

root@OSCTRL-UA:~# apt-get install heat-api heat-api-cfn heat-engine python-heatclient
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-heatclient is already the newest version.
python-heatclient set to manually installed.
The following extra packages will be installed:
  docutils-common docutils-doc heat-common javascript-common libjbig0
  libjs-jquery-hotkeys libjs-jquery-isonscreen libjs-jquery-metadata
  libjs-jquery-tablesorter liblcms2-2 libpaper-utils libpaper1 libpq5 libtiff5
  libwebp5 libwebpmux1 pep8 pyflakes python-coverage python-docutils
  python-egenix-mxdatetime python-egenix-mxtools python-extras python-fixtures
  python-flake8 python-hacking python-heat python-mccabe python-mimeparse
  python-oslosphinx python-pil python-psycopg2 python-pygments python-roman
  python-sphinx python-testtools python3-pkg-resources sphinx-common
  sphinx-doc
Suggested packages:
  liblcms2-utils texlive-latex-recommended texlive-latex-base
  texlive-lang-french fonts-linuxlibertine ttf-linux-libertine
  python-egenix-mxdatetime-dbg python-egenix-mxdatetime-doc
  python-egenix-mxtools-dbg python-egenix-mxtools-doc python-pil-doc
  python-pil-dbg python-psycopg2-doc ttf-bitstream-vera jsmath libjs-mathjax
  dvipng texlive-latex-extra texlive-fonts-recommended python-twisted
  python3-setuptools
The following NEW packages will be installed:
  docutils-common docutils-doc heat-api heat-api-cfn heat-common heat-engine
  javascript-common libjbig0 libjs-jquery-hotkeys libjs-jquery-isonscreen
  libjs-jquery-metadata libjs-jquery-tablesorter liblcms2-2 libpaper-utils
  libpaper1 libpq5 libtiff5 libwebp5 libwebpmux1 pep8 pyflakes python-coverage
  python-docutils python-egenix-mxdatetime python-egenix-mxtools python-extras
  python-fixtures python-flake8 python-hacking python-heat python-mccabe
  python-mimeparse python-oslosphinx python-pil python-psycopg2
  python-pygments python-roman python-sphinx python-testtools
  python3-pkg-resources sphinx-common sphinx-doc
0 upgraded, 42 newly installed, 0 to remove and 44 not upgraded.
Need to get 5,747 kB of archives.
After this operation, 28.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

 

11. Edit the /etc/heat/heat.conf file and update following sections.

In [database] section,

[database]
connection = mysql://heat:heatdb123@OSCTRL-UA/heat

In [DEFAULT] section,

[DEFAULT]
rpc_backend = rabbit
rabbit_host = OSCTRL-UA
rabbit_password = rabbit123
heat_metadata_server_url = http://OSCTRL-UA:8000
heat_waitcondition_server_url = http://OSCTRL-UA:8000/v1/waitcondition

In [keystone_authtoken] section,

[keystone_authtoken]
auth_uri = http://OSCTRL-UA:5000/v2.0
identity_uri = http://OSCTRL-UA:35357
admin_tenant_name = service
admin_user = heat
admin_password = heat123

In [ec2authtoken] section,

[ec2authtoken]
auth_uri = http://OSCTRL-UA:5000/v2.0

 

12. Populate the HEAT Orchestration database .

root@OSCTRL-UA:~# su -s /bin/sh -c "heat-manage db_sync" heat
root@OSCTRL-UA:~#

 

13. Remove the SQLlite database.

root@OSCTRL-UA:~# rm -f /var/lib/heat/heat.sqlite
root@OSCTRL-UA:~#

 

14.Restart the HEAT Orchestration services.

root@OSCTRL-UA:~# service heat-api restart
heat-api stop/waiting
heat-api start/running, process 34796
root@OSCTRL-UA:~# service heat-api-cfn restart
heat-api-cfn stop/waiting
heat-api-cfn start/running, process 34810
root@OSCTRL-UA:~# service heat-engine restart
stop: Unknown instance:
heat-engine start/running, process 34825
root@OSCTRL-UA:~#

We have successfully installed and configured the HEAT Orchestration on your openstack environment.

 

 

Verify the HEAT configuration:

 

1. Login to the controller node.

2. Source the tenant “lingesh” credentials .

root@OSCTRL-UA:~# cat lingesh.rc
export OS_USERNAME=lingesh
export OS_PASSWORD=ling123
export OS_TENANT_NAME=lingesh
export OS_AUTH_URL=http://OSCTRL-UA:35357/v2.0
root@OSCTRL-UA:~# source lingesh.rc
root@OSCTRL-UA:~#

 

3. Create the YAML language template file for HEAT in the name of “uah-stack.yml”.

heat_template_version: 2014-10-16
description: simple tiny server

parameters:
  ImageID:
    type: string
    description: Image use to boot a server
  NetID:
    type: string
    description: Network ID for the server

resources:
  server:
    type: OS::Nova::Server
    properties:
      image: { get_param: ImageID }
      flavor: m1.tiny
      networks:
      - network: { get_param: NetID }

outputs:
  private_ip:
    description: IP address of the server in the private network
    value: { get_attr: [ server, first_address ] }

 

4. List the available network.

root@OSCTRL-UA:~# nova net-list
+--------------------------------------+-------------+------+
| ID                                   | Label       | CIDR |
+--------------------------------------+-------------+------+
| 1c233704-4067-44ce-bc8c-eb1964c4a74a | ext-net     | None |
| 58ee8851-06c3-40f3-91ca-b6d7cff609a5 | lingesh-net | None |
+--------------------------------------+-------------+------+
root@OSCTRL-UA:~#

 

5. List the available glance images.

root@OSCTRL-UA:~# glance image-list
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
| ID                                   | Name                | Disk Format | Container Format | Size     | Status |
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
| 7d19b639-6950-42dc-a64d-91c6662e0613 | CirrOS 0.3.0        | qcow2       | bare             | 9761280  | active |
| 95fafce7-ae0f-47e3-b1c9-5d2ebd1af885 | CirrOS-0.3.4-x86_64 | qcow2       | bare             | 13287936 | active |
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
root@OSCTRL-UA:~#

 

6.Create the NET_ID variable with available network.

root@OSCTRL-UA:~# NET_ID=$(nova net-list | awk '/ lingesh-net / { print $2 }')
root@OSCTRL-UA:~#

 

7.Create the stack from template.

root@OSCTRL-UA:~# heat stack-create -f uah-stack.yml -P "ImageID=CirrOS-0.3.4-x86_64;NetID=$NET_ID" uhnstack
+--------------------------------------+------------+--------------------+----------------------+
| id                                   | stack_name | stack_status       | creation_time        |
+--------------------------------------+------------+--------------------+----------------------+
| 5e66777c-ea0a-4d5a-adff-f500bd718fae | uhnstack   | CREATE_IN_PROGRESS | 2015-10-22T12:04:58Z |
+--------------------------------------+------------+--------------------+----------------------+
root@OSCTRL-UA:~#

 

8.Verify the stack create progress.

root@OSCTRL-UA:~# heat stack-list
+--------------------------------------+------------+-----------------+----------------------+
| id                                   | stack_name | stack_status    | creation_time        |
+--------------------------------------+------------+-----------------+----------------------+
| 5e66777c-ea0a-4d5a-adff-f500bd718fae | uhnstack   | CREATE_COMPLETE | 2015-10-22T12:04:58Z |
+--------------------------------------+------------+-----------------+----------------------+
root@OSCTRL-UA:~#

 

9.In the back-end, instance will be launched.

root@OSCTRL-UA:~# nova list
+--------------------------------------+------------------------------+--------+------------+-------------+-------------------------+
| ID                                   | Name                         | Status | Task State | Power State | Networks                |
+--------------------------------------+------------------------------+--------+------------+-------------+-------------------------+
| 863cc74a-49fd-4843-83c8-bc9597cae2ff | uhnstack-server-udq3chnqb6t2 | ACTIVE | -          | Running     | lingesh-net=192.168.4.6 |
+--------------------------------------+------------------------------+--------+------------+-------------+-------------------------+
root@OSCTRL-UA:~#

 

Using HEAT, we can also create the auto-scaling stack where the instacne will be turned on based on the resource utilization.  Here is the sample auto-scaling template.

heat_template_version: 2014-10-16  
description: A simple auto scaling group.  
resources:  
  group:
    type: OS::Heat::AutoScalingGroup
    properties:
      cooldown: 60
      desired_capacity: 2
      max_size: 5
      min_size: 1
      resource:
        type: OS::Nova::Server::Cirros

  scaleup_policy:
    type: OS::Heat::ScalingPolicy
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: { get_resource: group }
      cooldown: 60
      scaling_adjustment: 1

  cpu_alarm_high:
    type: OS::Ceilometer::Alarm
    properties:
      meter_name: cpu_util
      statistic: avg
      period: 60
      evaluation_periods: 1
      threshold: 50
      alarm_actions:
        - {get_attr: [scaleup_policy, alarm_url]}
      comparison_operator: gt

 

You can download many heat templates from https://github.com/openstack/heat-templates 

 

Hope this article will be informative to you. Share it ! Be Sociable !!!

VMTURBO-CLOUD-CAPACITY

Leave a Reply

Your email address will not be published. Required fields are marked *