OpenStack Antelope : How to use Heat2023/04/19 |
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)]#
dnf --enablerepo=centos-openstack-antelope,epel,crb -y install python3-heatclient 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 | +--------------------------------------+----------------+--------+ | 17d50b54-c009-45ff-96ed-58086f79065f | CentOS-Stream9 | active | +--------------------------------------+----------------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 913ec733-5a60-4df0-b182-49a393675bca | private | bd8d7602-95e4-4540-971e-a0104dd8b658 | | c1c6a4c6-776e-4c4f-b557-b9efc4a43ee8 | public | 68cec7d2-f12f-4272-ac16-8dba6148888b | +--------------------------------------+---------+--------------------------------------+[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 | a46195c1-5759-44aa-aabf-c4b4c798155c | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2023-04-19T02:40:25Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | a46195c1-5759-44aa-aabf-c4b4c798155c | Sample-Stack | fa1902e20298477e9e065c0a330e1b6f | CREATE_COMPLETE | 2023-04-19T02:40:25Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template [root@dlp ~(keystone)]# openstack server list +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | 81216b3c-ffbf-4445-b9fb-2acb8f859292 | Heat_Deployed_Server | ACTIVE | private=192.168.100.252 | CentOS-Stream9 | m1.small | +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ # delete the instance [root@dlp ~(keystone)]# openstack stack delete --yes Sample-Stack
[root@dlp ~(keystone)]#
[root@dlp ~(keystone)]# openstack stack list 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 | +----------------------------------+------------------+ | 1137ffd38d064299a242e39be5712b13 | admin | | 2bffc2b99c164b6aaa8ffd1f61b49280 | reader | | 837745ef52fe416f94fc6a9fa27632f3 | heat_stack_owner | | bcc9e8bce2ca4a14b78fc11476de05b5 | member | | de9ddd7ad2334824b1ca5dd84a895740 | heat_stack_user | +----------------------------------+------------------+[root@dlp ~(keystone)]# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 40aa0807595447f0bd8d5b2dbfa1839b | hiroshima | | 6d680c2574034967ab496a59d1319a65 | service | | fa1902e20298477e9e065c0a330e1b6f | admin | +----------------------------------+-----------+[root@dlp ~(keystone)]# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 348d42a5169e497dac7507e81a8e0025 | admin | | 070609e07e334f788a06a73ff4ea86e0 | glance | | e306447682684dd891022b55351728cb | nova | | 38c69c74b8b54369ade01e902f5f5ffc | placement | | a017893c63a14712bf82b053795f716c | neutron | | 3c87f0d4e2e6413aa110a4240357cd97 | serverworld | | 879e12e5f24e4ec3aef3b036269a1d76 | cinder | | ec10791d3f7e439b80341b8fa05819bc | heat | | 03c9254b67d94c24bc507d7ff1154335 | 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 | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 2eaf56f3-a4cc-4192-aa32-af6fa01eb908 | Sample-Stack | CREATE_COMPLETE | 2023-04-19T02:44:55Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+[cent@dlp ~(keystone)]$ openstack server list +--------------------------------------+----------------------+---------+-------------------------------------+----------------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+-------------------------------------+----------------+-----------+ | a062a03d-dee5-4893-9b11-f866bea99930 | Heat_Deployed_Server | ACTIVE | private=192.168.100.125 | CentOS-Stream9 | m1.small | | 284a5b69-7b76-49c3-8180-c9b22284d429 | CentOS-St9 | SHUTOFF | private=10.0.0.229, 192.168.100.140 | CentOS-Stream9 | m1.medium | +--------------------------------------+----------------------+---------+-------------------------------------+----------------+-----------+ |
Sponsored Link |