CentOS Stream 9
Sponsored Link

OpenStack Bobcat : How to use Heat2023/10/25

 
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 Bobcat, EPEL, CRB

[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-bobcat,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 |
+--------------------------------------+----------------+--------+
| bcbaa323-2438-4f5e-9473-49f633bb8f9b | CentOS-Stream9 | active |
+--------------------------------------+----------------+--------+

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

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 1245127b-0e5c-49c1-8638-de9d51c34949 | private | 88416326-c3b5-4e6f-bf53-71a77c213721 |
| 44e70c99-2e15-429b-9dcc-cccaac557c0c | public  | fac5715e-35f6-4007-9e8f-edffb2629eeb |
+--------------------------------------+---------+--------------------------------------+

[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                  | 77785ddd-6bdd-4118-87d5-46b7278d2ebd |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2023-10-25T04:19:12Z                 |
| 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 |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 77785ddd-6bdd-4118-87d5-46b7278d2ebd | Sample-Stack | d9d13fdc603c42f69a0ea034b64a3cdb | CREATE_COMPLETE | 2023-10-25T04:19:12Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

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

+--------------------------------------+----------------------+--------+------------------------+----------------+----------+
| ID                                   | Name                 | Status | Networks               | Image          | Flavor   |
+--------------------------------------+----------------------+--------+------------------------+----------------+----------+
| 1df448f8-ca58-4e8f-b7da-e0f39ae70bc5 | Heat_Deployed_Server | ACTIVE | private=192.168.100.36 | 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             |
+----------------------------------+------------------+
| 47337a4ce8bc428a8b39bb8e32ad6a22 | reader           |
| 6a0da2e6047d4fabb752ef05e628c19d | manager          |
| 6ae93bec02354a19a18d0cae975034fe | member           |
| b4b84af37fc34fc78efa5ab4b8595abe | service          |
| b4ba3b0aa39e4789b3e5ac1100dbbcda | heat_stack_user  |
| cacd2a524a2b47e1b8c4e4d6906ed2fd | admin            |
| f24c7e0ee421455895f15f726cd7ca77 | heat_stack_owner |
+----------------------------------+------------------+

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

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 5d97881520b34e6bbf1f15e778c82fe4 | service   |
| d9d13fdc603c42f69a0ea034b64a3cdb | admin     |
| f4598dfd3b8a47149234b6892d18d5a4 | hiroshima |
+----------------------------------+-----------+

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

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| f551447b6e4a4593ba4172942385b4d8 | admin             |
| c5b1b17555cb4865b57936019cc63b1f | glance            |
| 44499d297d7e4449bbdb63ef6c6013dd | nova              |
| a4786e29c5f14ccc94a50adc133249bb | placement         |
| 6800bf9762fd4a5b823dbedf60ec6181 | neutron           |
| d70a5f7908de4cd9aa8e189b725244a9 | serverworld       |
| 41a29789f66e4f5787acba22bd4c5490 | cinder            |
| 77a3c465363a4026857fb7e3895c51d4 | heat              |
| febc43063411454fb9c2c4e77f82b220 | 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 |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 7451c26c-1517-4343-b274-1fd883b29a68 | Sample-Stack | CREATE_COMPLETE | 2023-10-25T04:23:22Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+

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

+--------------------------------------+----------------------+---------+------------------------------------+----------------+-----------+
| ID                                   | Name                 | Status  | Networks                           | Image          | Flavor    |
+--------------------------------------+----------------------+---------+------------------------------------+----------------+-----------+
| b655b78b-935f-4891-b72b-5287ab7daebf | Heat_Deployed_Server | ACTIVE  | private=192.168.100.60             | CentOS-Stream9 | m1.small  |
| 78b8c394-be14-4312-84e8-06eeebbd74f3 | CentOS-St9           | SHUTOFF | private=10.0.0.208, 192.168.100.63 | CentOS-Stream9 | m1.medium |
+--------------------------------------+----------------------+---------+------------------------------------+----------------+-----------+
Matched Content