OpenStack Zed : How to use Heat2023/06/29 |
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 | | Neutron L2/L3 Agent | | Libvirt | | Memcached Nginx | | Neutron Metadata | | Nova Compute | | Keystone httpd | | Open vSwitch | | Neutron L2 Agent | | Glance Nova API | | iSCSI Target | | Open vSwitch | | Neutron Server | | Cinder Volume | | | | Neutron Metadata | | Heat API/Engine | | | | Cinder API | | | | | +-----------------------+ +-----------------------+ +-----------------------+ |
[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 | +--------------------------------------+----------+--------+ | 3a660af6-3f41-4c0f-b2a8-55127dfc3c60 | Debian12 | active | +--------------------------------------+----------+--------+root@dlp ~(keystone)# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | ae5fdb1f-efb9-412b-9053-b81106c90336 | private | b3234f3f-b3e3-41d2-b3a4-ca3d4ec55d24 | | b9b8536b-0696-4a5b-af05-602587435c0a | public | 0129c597-e411-450e-a4f9-b387c68eddb3 | +--------------------------------------+---------+--------------------------------------+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=Debian12;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | c49bb959-915e-499a-b5f4-583172d24f36 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2023-06-29T05:43:36Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | c49bb959-915e-499a-b5f4-583172d24f36 | Sample-Stack | 757625ae78404e38a8cfdd7c6d262860 | CREATE_COMPLETE | 2023-06-29T05:43:36Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template root@dlp ~(keystone)# openstack server list +--------------------------------------+----------------------+--------+-------------------------+----------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+-------------------------+----------+----------+ | 34ab285f-b8a6-4f4f-9180-671c06dcd6c2 | Heat_Deployed_Server | ACTIVE | private=192.168.100.244 | Debian12 | 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 | +----------------------------------+------------------+ | 109c6488ef4347d681ba691f8ac97a6b | member | | 6055174790cd4797ae3671b38d935c53 | service | | 81f2687109a245b580690b6e8f9095db | heat_stack_owner | | 82699442db4e4edea2fb7986340b5ab4 | admin | | db9927603e564f94b2f0a4312d1a63da | heat_stack_user | | eb3d0d5b10cd456093463a2c12e41b82 | reader | +----------------------------------+------------------+root@dlp ~(keystone)# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 1c2f5dc8c4f9494fbaaa4217c8e3585a | hiroshima | | 757625ae78404e38a8cfdd7c6d262860 | admin | | d8b09d86ed7743039f92b2e542ea26c1 | service | +----------------------------------+-----------+root@dlp ~(keystone)# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | a45313c73c4842d7b5ba90f56be73de2 | admin | | b166b462bd214a34b99e079c806bef55 | glance | | 9fb0ad5b33f9492594f4139f5b428dab | nova | | 5db174d072dd4bcc90d34d7b0c4f0e36 | placement | | 1b4f2549a8ee462d909185b6a321e265 | neutron | | de51d5f0ee2c485885877d21f5b424e0 | serverworld | | 5b1712badfdb4824927488f7882cc7ca | cinder | | f485fdd327064f56ac0182c3b084525b | heat | | 65993a5e1fe0476486e82091276c2827 | 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 debian@dlp ~(keystone)$ openstack stack list +--------------------------------------+--------------+-----------------+----------------------+--------------+ | ID | Stack Name | Stack Status | Creation Time | Updated Time | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 9df1c577-abb5-4fa9-ad5e-d3869ed178a3 | Sample-Stack | CREATE_COMPLETE | 2023-06-29T05:46:45Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+debian@dlp ~(keystone)$ openstack server list +--------------------------------------+----------------------+---------+------------------------------------+----------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+------------------------------------+----------+-----------+ | e1402488-fbab-4d48-8bb1-957f0691a749 | Heat_Deployed_Server | ACTIVE | private=192.168.100.25 | Debian12 | m1.small | | c3a4a792-a7ac-41bd-8c93-7fd162016f22 | Debian-12 | SHUTOFF | private=10.0.0.241, 192.168.100.66 | Debian12 | m1.medium | +--------------------------------------+----------------------+---------+------------------------------------+----------+-----------+ |
Sponsored Link |