Ubuntu 22.04
Sponsored Link

OpenStack Bobcat : How to use Heat2023/10/06

 
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 |
+--------------------------------------+------------+--------+
| 2216b5ad-eeb5-4b9a-b862-60b84fdfee1c | Ubuntu2204 | active |
+--------------------------------------+------------+--------+

root@dlp ~(keystone)#
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 1d42f5e1-1ff2-4f70-8c48-8c7f6eae0672 | public  | c192082c-f107-4eed-aafc-6e30b604e283 |
| 529ae54a-4bba-40a3-905d-2ca57557236a | private | e14c5e7d-41d0-4378-af0f-0993c4389593 |
+--------------------------------------+---------+--------------------------------------+

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                  | 7e606bd3-fba4-4785-8358-3a69ed8e3679 |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2023-10-06T06:50:48Z                 |
| 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 |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 7e606bd3-fba4-4785-8358-3a69ed8e3679 | Sample-Stack | 39e8c6d7a2d14ee581902f0703a53b66 | CREATE_COMPLETE | 2023-10-06T06:50:48Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

root@dlp ~(keystone)#
openstack server list

+--------------------------------------+----------------------+--------+-------------------------+------------+----------+
| ID                                   | Name                 | Status | Networks                | Image      | Flavor   |
+--------------------------------------+----------------------+--------+-------------------------+------------+----------+
| d8228ea4-3ec1-4d4d-bde9-3399924270d6 | Heat_Deployed_Server | ACTIVE | private=192.168.100.153 | 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             |
+----------------------------------+------------------+
| 0d41776fe92a4875a4aeda03f4804def | service          |
| 1d6a75014fac4882853dcdf9005d2ac0 | member           |
| 3d73c1188d2f4f9faeebaddac60a3b39 | heat_stack_owner |
| 4e94de018ab9461484883e182a59f587 | heat_stack_user  |
| 7e9cba7b97f24cdfadba96d81da21b61 | admin            |
| a7176a75921345a4b3f0ccfa798650e5 | reader           |
+----------------------------------+------------------+

root@dlp ~(keystone)#
openstack project list

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 04b6d7802d9043cbb09ceb31fd68987b | service   |
| 39e8c6d7a2d14ee581902f0703a53b66 | admin     |
| f30cd546632e484cb24414d83207694b | hiroshima |
+----------------------------------+-----------+

root@dlp ~(keystone)#
openstack user list

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| c56785fb578043cdaf3823be08aa0462 | admin             |
| fe176e67ad1b44aaaae7d9a00c88f00c | glance            |
| 056259f270e843fcbb9e26121fdd2dc4 | nova              |
| e804b7ce81754ff7a30680aa5463fccd | placement         |
| e36439c68d254a03a81cdfb094f71038 | neutron           |
| 470c9323dad64bbea8fb5ecca6381f72 | serverworld       |
| ed62285b58404a5398d3f5676ccce673 | cinder            |
| 01e251593d7940a5ba596fd9c5531306 | heat              |
| 570937d8898d42a591aa00a5d326c227 | 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 |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 7e23d859-923c-41a9-ae0b-33a458b30216 | Sample-Stack | CREATE_COMPLETE | 2023-10-06T06:55:47Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+----------------------+---------+------------------------------------+------------+-----------+
| ID                                   | Name                 | Status  | Networks                           | Image      | Flavor    |
+--------------------------------------+----------------------+---------+------------------------------------+------------+-----------+
| 8f187059-85e9-45a3-8d4f-78ef9877b5c8 | Heat_Deployed_Server | ACTIVE  | private=192.168.100.36             | Ubuntu2204 | m1.small  |
| 530698ed-413e-4bda-b02e-8f6f60380bd1 | Ubuntu-2204          | SHUTOFF | private=10.0.0.222, 192.168.100.79 | Ubuntu2204 | m1.medium |
+--------------------------------------+----------------------+---------+------------------------------------+------------+-----------+
Matched Content