OpenStack Yoga : How to use Heat2022/05/04 |
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 httpd | | Neutron Server | | Nova Compute | | Keystone Glance | | OVN-Northd | | Open vSwitch | | Nova API Cinder API | | Cinder Volume | | OVN Metadata Agent | | | | Heat API/Engine | | OVN-Controller | +-----------------------+ +-----------------------+ +-----------------------+ |
[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 | +--------------------------------------+------------+--------+ | 70f856cc-6f3a-4cc3-b576-53f829a6d714 | Ubuntu2204 | active | +--------------------------------------+------------+--------+root@dlp ~(keystone)# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 2d24c223-3059-4143-baea-c8dea27232b5 | private | a602f687-a0d5-4d8d-ba1f-51e7c87a606b | | ad1337fe-7b67-4e87-b4c4-9480bd60df8e | public | f7fb2250-794e-4b55-af48-29816ed2a9ea | +--------------------------------------+---------+--------------------------------------+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=Ubuntu2204;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | 0239fa43-29c3-4099-9190-5e7011569198 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2022-05-03T23:03:31Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | 0239fa43-29c3-4099-9190-5e7011569198 | Sample-Stack | de339c4cb5984140ab0b243364e3a0f7 | CREATE_COMPLETE | 2022-05-03T23:03:31Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template root@dlp ~(keystone)# openstack server list +--------------------------------------+----------------------+--------+-------------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+-------------------------+------------+----------+ | d3e337dd-8403-4a22-b83b-d67b44b3e7c2 | Heat_Deployed_Server | ACTIVE | private=192.168.100.123 | Ubuntu2204 | 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 common users, it needs to change some settings. |
root@dlp ~(keystone)# openstack role list +----------------------------------+------------------+ | ID | Name | +----------------------------------+------------------+ | 21e8f80a7084427ea8a668bb50600a47 | CloudUser | | 269a9e935bd04d4f91d3ab60bc4c7b9f | admin | | 2eb6d717dcf54c52b4900fab860d2291 | heat_stack_owner | | 2f380d2d551e42abb4d3f0331fde775b | member | | 95dc5ec4279740599481a04271786f5b | reader | | f85bd7c7d2234471b42915b885c5c542 | heat_stack_user | +----------------------------------+------------------+root@dlp ~(keystone)# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 66102fdb888d4556a59dcff8b631ffdf | hiroshima | | c1c4d9a5313f43bd9f6f555e2d34ab28 | service | | de339c4cb5984140ab0b243364e3a0f7 | admin | +----------------------------------+-----------+root@dlp ~(keystone)# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 34113f89b81645c685255f27d4151cb5 | admin | | 41e315e920474fabad0bce94fd4e7db6 | glance | | df788fe920e6467c852a8198e87f6859 | nova | | 628c558c47b542d79d9b4c91e5ef5241 | placement | | 28aa64fdf6be4a7bbdf5179dc4187571 | neutron | | 74a373164921492ca35d32fea0fd2d86 | serverworld | | b38aa63c893c4d7da3f7aaea617cec5c | cinder | | 0383064a5cda4da490c6f7601209dcad | heat | | a40bc63dd177486b885deed6a0b01029 | 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
# on the Node Neutron Server is running, change settings root@network:~# vi /etc/neutron/policy.json # create new # overwrite some settings { "create_port:fixed_ips:subnet_id": "", "create_port:allowed_address_pairs": "", "create_port:allowed_address_pairs:ip_address": "", }
root@network:~# systemctl restart neutron-server
# that's OK, common users can create stacks ubuntu@dlp ~(keystone)$ openstack stack list +--------------------------------------+--------------+-----------------+----------------------+--------------+ | ID | Stack Name | Stack Status | Creation Time | Updated Time | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 1ac5e646-76b8-4ba9-aefb-bd35b4d17e34 | Sample-Stack | CREATE_COMPLETE | 2022-05-03T23:12:35Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+ubuntu@dlp ~(keystone)$ openstack server list +--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+ | 18085ac8-7d9c-4a0d-b701-c48c9d2200f5 | Heat_Deployed_Server | ACTIVE | private=192.168.100.99 | Ubuntu2204 | m1.small | | 6781b9c7-19c6-4419-a910-d0ae43c7526c | Ubuntu-2204 | SHUTOFF | private=10.0.0.203, 192.168.100.164 | Ubuntu2204 | m1.small | +--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+ |
Sponsored Link |
|