Ubuntu 22.04
Sponsored Link

OpenStack Antelope : How to use Heat2023/03/27

 
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  |  |      Open vSwitch     |  |        Libvirt        |
|  Memcached  Nginx     |  |     Neutron Server    |  |      Nova Compute     |
|  Keystone   httpd     |  |      OVN-Northd       |  |      Open vSwitch     |
|  Glance     Nova API  |  |  Nginx  iSCSI Target  |  |   OVN Metadata Agent  |
|  Cinder API           |  |     Cinder Volume     |  |     OVN-Controller    |
|                       |  |    Heat API/Engine    |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

[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 |
+--------------------------------------+------------+--------+
| 00ea6e97-0e97-4cb4-8ac4-2409c28f0289 | Ubuntu2204 | active |
+--------------------------------------+------------+--------+

root@dlp ~(keystone)#
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 5352e6c0-47b3-4df2-84f4-ca048f141e1d | public  | ca5539a8-0291-4684-9fb3-0f448efacebf |
| ce6e88bc-107a-446b-b2ab-255bab7269fe | private | feb337ec-215e-406e-8871-196fed2c4207 |
+--------------------------------------+---------+--------------------------------------+

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                  | b86ea144-9d9a-43b4-a04b-1feaa09ada14 |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2023-03-27T07:30:24Z                 |
| 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 |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| b86ea144-9d9a-43b4-a04b-1feaa09ada14 | Sample-Stack | cac657ec003e4c95aaaa30bc0321895f | CREATE_COMPLETE | 2023-03-27T07:30:24Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

root@dlp ~(keystone)#
openstack server list

+--------------------------------------+----------------------+--------+------------------------+------------+----------+
| ID                                   | Name                 | Status | Networks               | Image      | Flavor   |
+--------------------------------------+----------------------+--------+------------------------+------------+----------+
| 78d363a3-f137-46db-b486-eed2a5a14ae3 | Heat_Deployed_Server | ACTIVE | private=192.168.100.84 | Ubuntu2204 | 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
[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             |
+----------------------------------+------------------+
| 3f31c91423a240e6bea892e4558fc1e6 | heat_stack_owner |
| 43c012ff4b1349f09b928ece32c00777 | heat_stack_user  |
| 9ef8c6b3f07544fa8fbda60043be9ab4 | reader           |
| e06201251dca4570839521f089b961d3 | member           |
| f8ab227f0a1b4c1ba730ec919741482f | admin            |
+----------------------------------+------------------+

root@dlp ~(keystone)#
openstack project list

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| cac657ec003e4c95aaaa30bc0321895f | admin     |
| d3dd87fb1a034f7883539a6a4f83781f | service   |
| e294bd7c00314facacdb46c36fb54ee9 | hiroshima |
+----------------------------------+-----------+

root@dlp ~(keystone)#
openstack user list

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| 3f8408ddae654aed8ffd07d667a92e24 | admin             |
| b0eb7a7d5077484eb43ac73eff8f2215 | glance            |
| a9613485a7f24f2d857f656ad9282ae3 | nova              |
| be7d5fd468c04daca48874019925938e | placement         |
| 131733f1a6e24197b47a4e9da6434ba2 | neutron           |
| 85236576a97e492791abe70c217c8898 | serverworld       |
| 1291621249e140b6b1b175a5a16303ee | cinder            |
| 246eeda313194b32bfa735d76e670ac3 | heat              |
| 903347ea9bd14a75b991200b71be08ec | 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 |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 26ef0a47-3774-4b4c-9946-daf2348bd5c0 | Sample-Stack | CREATE_COMPLETE | 2023-03-27T07:34:40Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+----------------------+---------+-------------------------------------+------------+-----------+
| ID                                   | Name                 | Status  | Networks                            | Image      | Flavor    |
+--------------------------------------+----------------------+---------+-------------------------------------+------------+-----------+
| 45592651-144c-4fb9-bca1-564b321cc808 | Heat_Deployed_Server | ACTIVE  | private=192.168.100.60              | Ubuntu2204 | m1.small  |
| 11987eec-fb38-4de1-a386-3d1d6001bbd3 | Ubuntu-2204          | SHUTOFF | private=10.0.0.252, 192.168.100.100 | Ubuntu2204 | m1.medium |
+--------------------------------------+----------------------+---------+-------------------------------------+------------+-----------+
Matched Content