Ubuntu 22.04
Sponsored Link

OpenStack Caracal : How to use Heat2024/04/09

 
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
+-----------+-----------+  +-----------+-----------+  +-----------+-----------+
|   [ dlp.srv.world ]   |  | [ network.srv.world ] |  |  [ node01.srv.world ] |
|     (Control Node)    |  |     (Network Node)    |  |     (Compute Node)    |
|                       |  |                       |  |                       |
|  MariaDB    RabbitMQ  |  |  Neutron L2/L3 Agent  |  |        Libvirt        |
|  Memcached  Nginx     |  |   Neutron Metadata    |  |      Nova Compute     |
|  Keystone   httpd     |  |     Open vSwitch      |  |    Neutron L2 Agent   |
|  Glance     Nova API  |  |     iSCSI Target      |  |      Open vSwitch     |
|  Neutron Server       |  |     Cinder Volume     |  |                       |
|  Neutron Metadata     |  |     Heat API/Engine   |  |                       |
|  Cinder API           |  |                       |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

[1] Deploy Instances with Heat services and templates. The example below is on the Control Node.
root@dlp ~(keystone)#
apt -y install python3-heatclient
# create a template for tests

root@dlp ~(keystone)#
vi sample-stack.yml
heat_template_version: 2021-04-16

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 |
+--------------------------------------+------------+--------+
| 76820d6f-918b-44ac-ad2f-c8075456ff45 | Ubuntu2204 | active |
+--------------------------------------+------------+--------+

root@dlp ~(keystone)#
openstack network list

+---------------------------------+---------+----------------------------------+
| ID                              | Name    | Subnets                          |
+---------------------------------+---------+----------------------------------+
| 24288203-5512-40c5-8bcb-        | public  | 0b39a7b6-3b03-4704-ba32-         |
| aed6dffc2bc1                    |         | 89e5894bad2c                     |
| b28ad879-8bbf-40fe-b2fb-        | private | 42dd9fb5-a0f2-4556-b896-         |
| af772cf88a8a                    |         | 6257cb5119f6                     |
+---------------------------------+---------+----------------------------------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | bc9c570b-2ff9-4650-8fb4-72b6e5ba49f2 |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2024-04-09T06:58:26Z                 |
| 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 |
+------------+------------+------------+--------------+---------------+--------------+
| bc9c570b-  | Sample-    | 62980715ee | CREATE_COMPL | 2024-04-      | None         |
| 2ff9-4650- | Stack      | 6d434eaf4e | ETE          | 09T06:58:26Z  |              |
| 8fb4-      |            | fddd9b63e9 |              |               |              |
| 72b6e5ba49 |            | d6         |              |               |              |
| f2         |            |            |              |               |              |
+------------+------------+------------+--------------+---------------+--------------+

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

root@dlp ~(keystone)#
openstack server list

+--------------+--------------+--------+---------------+------------+----------+
| ID           | Name         | Status | Networks      | Image      | Flavor   |
+--------------+--------------+--------+---------------+------------+----------+
| bf1c1167-    | Heat_Deploye | ACTIVE | private=192.1 | Ubuntu2204 | m1.small |
| 184d-403d-   | d_Server     |        | 68.100.84     |            |          |
| b468-        |              |        |               |            |          |
| aa3c07c28af3 |              |        |               |            |          |
+--------------+--------------+--------+---------------+------------+----------+

# 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
[3] If you'd like to use Heat with a common user, it needs to add the user in Heat role.
root@dlp ~(keystone)#
openstack role list

+----------------------------------+------------------+
| ID                               | Name             |
+----------------------------------+------------------+
| 3d69f0474abe48869999014caae40558 | admin            |
| 44bca5dd1676498996c6ca78f2b61cd2 | service          |
| 4cb545b66c61411f8c75d65708d650e9 | reader           |
| 68ac49b978524b0a99060b177ea96f60 | manager          |
| 6b2003ce3c3241aaaf6a70ea3e814de7 | member           |
| c563d10b879d48b5bf9013515f0a410f | heat_stack_user  |
| cd14b829a842488188299462ff4dd37e | heat_stack_owner |
+----------------------------------+------------------+

root@dlp ~(keystone)#
openstack project list

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 2bcdd2fecf1d4a8c8faf87f1232cf365 | hiroshima |
| 62980715ee6d434eaf4efddd9b63e9d6 | admin     |
| c9a28e6f0f794ccf889c115bb9c2872c | service   |
+----------------------------------+-----------+

root@dlp ~(keystone)#
openstack user list

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| 27a667fb6dd84abf950add9f36ad72ae | admin             |
| 98cc3b3090fa4f2683b0fd77ad849fe4 | glance            |
| 14118344ffac4cd180e77dedd181fa53 | nova              |
| 2bdae31834f3416a8eab803b5f25ef82 | placement         |
| bb6b7624bc6b45bdae1125db005133ff | neutron           |
| e682843492a44937b745ef945bfacf70 | serverworld       |
| 0f0b38d9c3a5423ebbdf92d26fcf3ddf | cinder            |
| a57f5ef4320d4944a6cc7e6372ada879 | heat              |
| 34ad5075ff2b4ef5a5f51e7278eacd04 | heat_domain_admin |
+----------------------------------+-------------------+

# for example, add [serverworld] user in [hiroshima] project to [heat_stack_owner] role

root@dlp ~(keystone)#
openstack role add --project hiroshima --user serverworld heat_stack_owner
# that's OK, common users can create stacks

ubuntu@dlp ~(keystone)$
openstack stack list

+---------------+--------------+---------------+----------------+--------------+
| ID            | Stack Name   | Stack Status  | Creation Time  | Updated Time |
+---------------+--------------+---------------+----------------+--------------+
| b89ffe65-     | Sample-Stack | CREATE_COMPLE | 2024-04-       | None         |
| 150a-44fe-    |              | TE            | 09T07:01:20Z   |              |
| 8dfd-         |              |               |                |              |
| 23d2726c4cfb  |              |               |                |              |
+---------------+--------------+---------------+----------------+--------------+

ubuntu@dlp ~(keystone)$
openstack server list

+--------------+--------------+---------+--------------+------------+----------+
| ID           | Name         | Status  | Networks     | Image      | Flavor   |
+--------------+--------------+---------+--------------+------------+----------+
| c41e770c-    | Heat_Deploye | ACTIVE  | private=192. | Ubuntu2204 | m1.small |
| ec24-4cdf-bc | d_Server     |         | 168.100.78   |            |          |
| 5c-          |              |         |              |            |          |
| 86af5897344a |              |         |              |            |          |
| e7feb65c-    | Ubuntu-2204  | SHUTOFF | private=10.0 | Ubuntu2204 | m1.small |
| 1482-48a9-   |              |         | .0.250, 192. |            |          |
| 9d45-        |              |         | 168.100.188  |            |          |
| e74196a5ea92 |              |         |              |            |          |
+--------------+--------------+---------+--------------+------------+----------+
Matched Content