OpenStack Dalmatian : How to use Heat2024/10/14 |
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 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 | +--------------------------------------+------------+--------+ | a9d10f1d-d836-424d-8117-ff3fc8c5e966 | Ubuntu2404 | active | +--------------------------------------+------------+--------+root@dlp ~(keystone)# openstack network list +---------------------------------+---------+----------------------------------+ | ID | Name | Subnets | +---------------------------------+---------+----------------------------------+ | 2da36a04-0d3e-4de8-9be8- | private | bc45dd3e-0b15-42ca-a37b- | | a2972c15bbe4 | | 94f2feaf341e | | ce38ba4f-6066-4e93-ae59- | public | 22837749-299e-4323-bfc3- | | de238fb6ed08 | | 3120c8c2d635 | +---------------------------------+---------+----------------------------------+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=Ubuntu2404;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | af3858c8-e170-415d-812b-e82209f0da8c | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2024-10-14T01:13:35Z | | 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 | +------------+------------+------------+--------------+---------------+--------------+ | af3858c8- | Sample- | 7b2284a868 | CREATE_COMPL | 2024-10- | None | | e170-415d- | Stack | dd4b119b40 | ETE | 14T01:13:35Z | | | 812b- | | 0ad76ae20f | | | | | e82209f0da | | de | | | | | 8c | | | | | | +------------+------------+------------+--------------+---------------+--------------+ # the instance is running which is created from the Heat template root@dlp ~(keystone)# openstack server list +--------------+--------------+--------+---------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+--------------+--------+---------------+------------+----------+ | 8950466f- | Heat_Deploye | ACTIVE | private=192.1 | Ubuntu2404 | m1.small | | 650a-43f6- | d_Server | | 68.100.92 | | | | 8cec- | | | | | | | 51123db9d7c7 | | | | | | +--------------+--------------+--------+---------------+------------+----------+ # 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 | +----------------------------------+------------------+ | 0c0e56e84a0741ffa6db6a21c8fefadd | member | | 777f0e020c0c45a5adc2ad3ab77f723f | service | | 85e48e4b84984b909e5b2b5e6edba766 | admin | | 8ac6e4f5c0d749d3beb6cdadcad1e321 | manager | | bc5f4baae4fa4e7080c66e8ba1da1660 | reader | | c03aacb803f6431fb603f22599527c79 | heat_stack_user | | e67d540be8b94bc19b2aaec739ddc232 | heat_stack_owner | +----------------------------------+------------------+root@dlp ~(keystone)# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 0b61bc880cd64b67946dd6352a138e30 | service | | 7b2284a868dd4b119b400ad76ae20fde | admin | | 84e315c8d65e4b3cb33aaf69c9eed0c3 | hiroshima | +----------------------------------+-----------+root@dlp ~(keystone)# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 76a9724ed247448d9c71a2ea67713063 | admin | | 2acfc92941ca4980964dc80ae4e1a1f4 | glance | | e6d0780b6c4844198fdc3d16fdd0f313 | nova | | 6c45736ec2b54565888b47a22be9fa1c | placement | | 73e92a3ca6bb4a5ba58d8a0a4bce449a | neutron | | d97d1aef1b234c469ad3757bcd51dfa4 | serverworld | | 461d084b1d134ccb8d4bf992a7369c9c | cinder | | 5c584c6f80b3425baa2818fead5582c9 | heat | | a9055cb90a6f4da19e1ca0ce8a657ca8 | 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 | +---------------+--------------+---------------+----------------+--------------+ | 65925254- | Sample-Stack | CREATE_COMPLE | 2024-10- | None | | a1ab-4819- | | TE | 14T01:17:55Z | | | b414- | | | | | | 7a0dc3df13ff | | | | | +---------------+--------------+---------------+----------------+--------------+ubuntu@dlp ~(keystone)$ openstack server list +--------------+--------------+---------+--------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+--------------+---------+--------------+------------+----------+ | a413d26a- | Heat_Deploye | ACTIVE | private=192. | Ubuntu2404 | m1.small | | e62d-4ff0- | d_Server | | 168.100.180 | | | | 99ad- | | | | | | | 30ffcd2bcfc7 | | | | | | | b8fcec95- | Ubuntu-2404 | SHUTOFF | private=10.0 | Ubuntu2404 | m1.small | | d25f-4f1f- | | | .0.203, 192. | | | | 95ec- | | | 168.100.99 | | | | 91ee1e0e66b1 | | | | | | +--------------+--------------+---------+--------------+------------+----------+ |
Sponsored Link |
|