OpenStack Caracal : How to use Heat2024/08/07 |
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-caracal,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 | +--------------------------------------+----------------+--------+ | cfa9783d-ca91-4e3b-8016-81e3336bd5f0 | CentOS-Stream9 | active | +--------------------------------------+----------------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 5bf02aae-1fef-4303-937a-74b8412bf90a | private | e32f2074-d33b-4b13-9605-1a29301f93a1 | | cedf14f5-e8ef-4577-a226-022f289f45fb | public | c8fcf916-a102-412a-8809-92f31bd3955e | +--------------------------------------+---------+--------------------------------------+[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 | d4102174-8fbd-45fa-80e5-3345a8bb1c68 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2024-08-07T05:03:30Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | d4102174-8fbd-45fa-80e5-3345a8bb1c68 | Sample-Stack | b62e60c6d4b7406a90eee2f2d9c45917 | CREATE_COMPLETE | 2024-08-07T05:03:30Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template [root@dlp ~(keystone)]# openstack server list +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | 58a56053-c437-45b3-8930-d6de41530df3 | Heat_Deployed_Server | ACTIVE | private=192.168.100.114 | 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 | +----------------------------------+------------------+ | 1029f54f585b431b93a5d8c15c70a839 | heat_stack_owner | | 2096b9d868f24aa4b879ead11fdfbd47 | reader | | 48a32d4ca9ef44dfb4c191d96620013f | admin | | 8fc9011839cb46e591dbde56d0179588 | manager | | c544d69550f44be19c2a7262940a90b0 | service | | f37cb3e2f3a8418d80bfbf658caeeffc | member | | f73e38c4c5404445a3fc0caf6e19cb72 | heat_stack_user | +----------------------------------+------------------+[root@dlp ~(keystone)]# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 03a31c43ede44dcbaacb05c870920e81 | hiroshima | | 0b826f1bf49d489494e94badc32f2cea | service | | b62e60c6d4b7406a90eee2f2d9c45917 | admin | +----------------------------------+-----------+[root@dlp ~(keystone)]# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 810ba3fbe4e14e3aa3bfbf7c3da7f893 | admin | | 7ba2cd7240734050a856b5a12efd2312 | glance | | dcf943060041487d84bd658d03cde7bf | nova | | d3e6144f4b41432ba39c135b627c844b | placement | | 1fe82e21d1724c57b192b0af02751447 | neutron | | 8a9b46168b42480f889ad4fad3ca6ee4 | serverworld | | d442d4c8e2514a41bf5bba14f97fb04a | cinder | | c1a7b8a4b97a4efb9141cf4ad34bbc6c | heat | | 04c85f8f2f4b48719f578c9d26c60cc1 | 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 | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 4b7ee2d1-007c-4b3f-92e7-ec01a80abf4e | Sample-Stack | CREATE_COMPLETE | 2024-08-07T05:06:07Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+[cent@dlp ~(keystone)]$ openstack server list +--------------------------------------+----------------------+---------+------------------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+------------------------------------+----------------+----------+ | 3bf4cb6c-a6a5-427a-b82a-51148b25f033 | Heat_Deployed_Server | ACTIVE | private=192.168.100.203 | CentOS-Stream9 | m1.small | | 1d0c2140-098d-4a1a-a705-82d7755d7c84 | CentOS-St9 | SHUTOFF | private=10.0.0.250, 192.168.100.65 | CentOS-Stream9 | m1.small | +--------------------------------------+----------------------+---------+------------------------------------+----------------+----------+ |
Sponsored Link |