OpenStack Wallaby : How to use Heat2021/04/20 |
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 +-----------+-----------+ +-----------+-----------+ +-----------+-----------+ | [ Control Node ] | | [ Storage Node ] | | [ Compute Node ] | | | | | | | | MariaDB RabbitMQ | | Open vSwitch | | Libvirt | | Memcached httpd | | Neutron Server | | Nova Compute | | Keystone Glance | | OVN-Northd | | Open vSwitch | | Nova API | | Cinder Volume | | OVN Metadata Agent | | Cinder API | | iSCSI Target | | OVN-Controller | | | | Heat API/Engine | | | +-----------------------+ +-----------------------+ +-----------------------+ |
[1] | Deploy Instances with Heat services and templates. The example below is on the Controle Node. |
root@dlp ~(keystone)#
apt -y install python3-heatclient heat_template_version: 2018-08-31 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 | +--------------------------------------+------------+--------+ | 8df08a02-7c19-465e-8862-53eb2319918d | Ubuntu2004 | active | +--------------------------------------+------------+--------+root@dlp ~(keystone)# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 04e8b9fa-9798-4595-a840-b0f6338e83e8 | public | 0b3c70ba-60d8-46c5-af21-910548abfbf9 | | 42c5be25-c9f0-467f-99bf-743a420abf03 | private | a39a9811-f7a4-49c1-80f1-f753bf27a11c | +--------------------------------------+---------+--------------------------------------+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=Ubuntu2004;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | 909eb55d-da96-4905-9b9f-48c643ec3d98 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2021-04-19T08:34:16Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | 909eb55d-da96-4905-9b9f-48c643ec3d98 | Sample-Stack | da2214d30eaa4b7aaae25c8cbba0483e | CREATE_COMPLETE | 2021-04-19T08:34:16Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template root@dlp ~(keystone)# openstack server list +--------------------------------------+----------------------+--------+-------------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+-------------------------+------------+----------+ | 762c9a4d-3a16-4e62-afe4-fb9b54191038 | Heat_Deployed_Server | ACTIVE | private=192.168.100.123 | Ubuntu2004 | 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 | +----------------------------------+------------------+ | 2d94fe600782461091f60a4d8a32b489 | reader | | 327e923f25754401a0b1fc1b8a16bf28 | heat_stack_owner | | 936654cab29047459ba7080aea91beff | member | | d257716c488e41dabaf3e4985bb6707b | CloudUser | | dd621362b3da49b68d4ad5cff8af764f | heat_stack_user | | edd5e08d3efb4ee9ada8713dc9b8ba83 | admin | +----------------------------------+------------------+root@dlp ~(keystone)# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | b1f2e1bdf6fb4e03bb30ef3b90764d3b | service | | da2214d30eaa4b7aaae25c8cbba0483e | admin | | e256a7323fda468fb02e8f1975fce488 | hiroshima | +----------------------------------+-----------+root@dlp ~(keystone)# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | dd9136aeab894d66bc6aff94ceba90a2 | admin | | 7b78d22f820441e89143555a34a88604 | glance | | 61abb3442b46467f848d653798763a6f | nova | | c2a87e720b1e4561824070fa1a2f8931 | placement | | 2383f0594a7a4e4bab995eaf96f6af9a | neutron | | 3ebb8ec1b4fc467da96379caef902df7 | serverworld | | 0eb6e22ca46b4746a03da8a9d472492f | cinder | | bd806f7ce39e4262ae0b7fc7ef439192 | heat | | 47443b84dc1f4e2287aeea6c4992c9db | 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 | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 8cae8ae4-4600-46bd-b5dc-eaf638773e12 | Sample-Stack | CREATE_COMPLETE | 2021-04-19T08:37:14Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+ubuntu@dlp ~(keystone)$ openstack server list +--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+ | a2c614b3-fdf4-43c8-ab0d-b5d80c276934 | Heat_Deployed_Server | ACTIVE | private=192.168.100.237 | Ubuntu2004 | m1.small | | 675fa368-4534-4d38-bc14-319a90f09470 | Ubuntu-2004 | SHUTOFF | private=10.0.0.207, 192.168.100.169 | Ubuntu2004 | m1.small | +--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+ |
Sponsored Link |
|