Ubuntu 20.04
Sponsored Link

OpenStack Ussuri : How to use Heat2020/06/18

 
How to use the OpenStack Orchestration Service (Heat).
This example is based on the environment like follows.
------------+---------------------------+---------------------------+------------
            |                           |                           |
        eth0|10.0.0.30              eth0|10.0.0.50              eth0|10.0.0.51
+-----------+-----------+   +-----------+-----------+   +-----------+-----------+
|    [ Control Node ]   |   |    [ Network Node ]   |   |    [ Compute Node ]   |
|                       |   |                       |   |                       |
|  MariaDB    RabbitMQ  |   |        L2 Agent       |   |        Libvirt        |
|  Memcached  httpd     |   |        L3 Agent       |   |     Nova Compute      |
|  Keystone   Glance    |   |     Metadata Agent    |   |        L2 Agent       |
|  Nova API             |   |     Cinder Volume     |   |                       |
|  Neutron Server       |   |       Heat API        |   |                       |
|  Metadata Agent       |   |      Heat Engine      |   |                       |
|  Cinder API           |   |                       |   |                       |
+-----------------------+   +-----------------------+   +-----------------------+

[1] Deploy Instances with Heat services and templates. The example below is on the Controle Node.
# create a template for test

root@dlp ~(keystone)#
vi sample-stack.yml
heat_template_version: 2018-08-31

description: Heat Sample Template

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

resources:
  server1:
    type: OS::Nova::Server
    properties:
      name: "Heat_Deployed_Server"
      image: { get_param: ImageID }
      flavor: "m1.small"
      networks:
      - network: { get_param: NetID }

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

root@dlp ~(keystone)#
openstack image list

+--------------------------------------+------------+--------+
| ID                                   | Name       | Status |
+--------------------------------------+------------+--------+
| de51f2d9-aa58-4a34-87d6-857451599d9a | Ubuntu2004 | active |
+--------------------------------------+------------+--------+

root@dlp ~(keystone)#
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 1f3f1f9b-4822-4312-b5a5-51a529cd6e8a | ext_net | ddfcdd10-7ecb-4239-b3d7-46fdd15a006d |
| b351e1b9-bd7c-4e3c-b5eb-848d211f4392 | int_net | e2a461fc-9d50-4bab-913f-14067b175ea6 |
+--------------------------------------+---------+--------------------------------------+

root@dlp ~(keystone)#
Int_Net_ID=$(openstack network list | grep int_net | awk '{ print $2 }')
# create an instance from the template

root@dlp ~(keystone)#
openstack stack create -t sample-stack.yml --parameter "ImageID=Ubuntu2004;NetID=$Int_Net_ID" Sample-Stack

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 0c419d97-adac-4407-a30c-e07e8171c059 |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2020-06-18T01:14:52Z                 |
| updated_time        | None                                 |
| stack_status        | CREATE_IN_PROGRESS                   |
| stack_status_reason | Stack CREATE started                 |
+---------------------+--------------------------------------+

# turn to [CREATE_COMPLETE] after few minutes later like follows

root@dlp ~(keystone)#
openstack stack list

+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name   | Project                          | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 0c419d97-adac-4407-a30c-e07e8171c059 | Sample-Stack | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e | CREATE_COMPLETE | 2020-06-18T01:14:52Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

# the instance is running which is created from the Heat template

root@dlp ~(keystone)#
openstack server list

+--------------------------------------+----------------------+--------+-------------------------+------------+----------+
| ID                                   | Name                 | Status | Networks                | Image      | Flavor   |
+--------------------------------------+----------------------+--------+-------------------------+------------+----------+
| 605f8ef4-9ecb-4da9-859e-28c351c30977 | Heat_Deployed_Server | ACTIVE | int_net=192.168.100.253 | Ubuntu2004 | m1.small |
+--------------------------------------+----------------------+--------+-------------------------+------------+----------+

# delete the instance

root@dlp ~(keystone)#
openstack stack delete --yes Sample-Stack

root@dlp ~(keystone)#
openstack stack list


[2]
The guide for writing templates are opened on the official site below.
⇒ https://docs.openstack.org/heat/latest/template_guide/index.html
Matched Content