CentOS Stream 9
Sponsored Link

OpenStack Dalmatian : How to use Heat2024/10/11

 

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.
# install Heat client from Dalmatian, EPEL, CRB

[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-dalmatian,epel,crb -y install python3-heatclient
# create a template for test

[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 |
+--------------------------------------+----------------+--------+
| 75e0d976-4075-4488-8f26-87d4a50aebe9 | CentOS-Stream9 | active |
+--------------------------------------+----------------+--------+

[root@dlp ~(keystone)]#
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 7302c07e-c543-4a85-a955-d6cc8a4e4011 | public  | 8fbc394a-e821-47d8-8efc-d5f7c7db0ff8 |
| aa200aa9-ddb2-4d89-aa37-ce3e3a939421 | private | dfb0949d-d775-4c17-9b07-b01ac7d71aac |
+--------------------------------------+---------+--------------------------------------+

[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=CentOS-Stream9;NetID=$Int_Net_ID" Sample-Stack

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 5b7ac3eb-ee41-49aa-a6e2-23b8a1a5e300 |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2024-10-11T06:48:00Z                 |
| updated_time        | None                                 |
| stack_status        | CREATE_IN_PROGRESS                   |
| stack_status_reason | Stack CREATE started                 |
+---------------------+--------------------------------------+

# turn to [CREATE_COMPLETE] after few minutes later

[root@dlp ~(keystone)]#
openstack stack list

+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name   | Project                          | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 5b7ac3eb-ee41-49aa-a6e2-23b8a1a5e300 | Sample-Stack | b19d04cd37254937a4eaebcd0f0f0a43 | CREATE_COMPLETE | 2024-10-11T06:48:00Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------------------+--------+-------------------------+----------------+----------+
| ID                                   | Name                 | Status | Networks                | Image          | Flavor   |
+--------------------------------------+----------------------+--------+-------------------------+----------------+----------+
| 067b09be-049b-46bb-ba1f-a15e8a731de4 | Heat_Deployed_Server | ACTIVE | private=192.168.100.232 | CentOS-Stream9 | m1.small |
+--------------------------------------+----------------------+--------+-------------------------+----------------+----------+

# delete the instance

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

[root@dlp ~(keystone)]#
openstack stack list
[root@dlp ~(keystone)]#
openstack server 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             |
+----------------------------------+------------------+
| 1d531758bc864a3cbb0d85e701aebbbb | heat_stack_user  |
| 325e5c0b45184b82a671d341b19de2aa | heat_stack_owner |
| 4cbffcb8460a472e9f248e8536b6b254 | admin            |
| 81e7f75a8ff44892b9a7c66b1bfce8ed | service          |
| 842b4194a02f4ae2849a88d20c9240b1 | member           |
| c29749ff7b354c4eb175e6d22a99bc14 | manager          |
| ec7c81493ae4438fb9ef1b6f333302c7 | reader           |
+----------------------------------+------------------+

[root@dlp ~(keystone)]#
openstack project list

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 756e2b4937c44d3991028e294f92d89a | hiroshima |
| aff8e7e402dc4d9e849bbe0e34fa4538 | service   |
| b19d04cd37254937a4eaebcd0f0f0a43 | admin     |
+----------------------------------+-----------+

[root@dlp ~(keystone)]#
openstack user list

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| 2848dbbdd1714726b5b9a105c1382618 | admin             |
| acc884feccc14373a1f9fc8dda806eee | glance            |
| b46ff6a5849c4e90ae4eb0aa4b43e098 | nova              |
| f18f2b8163d44d15beaf9e491bc399f6 | placement         |
| bed4478c6b3446338b95d41979485ee3 | neutron           |
| 19c7530debb54eb0bfe6dc47aae3df32 | serverworld       |
| ddd4329358524a38a69e0dfe3effe87e | cinder            |
| 99a4af2f51c34fdab3299f660ef1be2d | heat              |
| 3be7a60d447b46f58769630abac753ae | 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, allowed common users can create stacks

[cent@dlp ~(keystone)]$
openstack stack list

+--------------------------------------+--------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name   | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 1aed7f14-f157-467a-8062-032e1f639c56 | Sample-Stack | CREATE_COMPLETE | 2024-10-11T06:51:01Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+
| ID                                   | Name                 | Status  | Networks                            | Image          | Flavor   |
+--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+
| 57e00e0f-5b81-4ca9-9e5f-59e966eeb63f | Heat_Deployed_Server | ACTIVE  | private=192.168.100.146             | CentOS-Stream9 | m1.small |
| 3d753408-6705-4cbf-acd8-2e09d975b973 | CentOS-St9           | SHUTOFF | private=10.0.0.206, 192.168.100.103 | CentOS-Stream9 | m1.small |
+--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+
Matched Content