OpenStack Victoria : How to use Heat2021/03/24 |
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 ] | | [ Network 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)]#
dnf --enablerepo=centos-openstack-victoria,powertools,epel -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 | +--------------------------------------+-----------------+--------+ | 4d7293af-be5b-471b-9507-2a32f1955b11 | CentOS-Stream-8 | active | +--------------------------------------+-----------------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 9f53c3b1-ec6b-499d-854a-588d3b0b96d6 | private | 94afb0cc-1d58-4615-8fef-8852271bfc16 | | ea9725cf-a8bc-4eb5-a374-7d7d0e11453c | public | 63c29d7b-e870-477d-819b-e5dfe41af1d0 | +--------------------------------------+---------+--------------------------------------+[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-Stream-8;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | 784508fe-4b71-4a80-9cc4-b88e97eb453e | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2021-03-24T08:03:23Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | 784508fe-4b71-4a80-9cc4-b88e97eb453e | Sample-Stack | b9bf51c6436a4c5aa7a2df05688afb49 | CREATE_COMPLETE | 2021-03-24T08:03:23Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template [root@dlp ~(keystone)]# openstack server list +--------------------------------------+----------------------+--------+------------------------+-----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+------------------------+-----------------+----------+ | 105acdb0-1f84-42e2-b5e4-45c184aae40d | Heat_Deployed_Server | ACTIVE | private=192.168.100.61 | CentOS-Stream-8 | 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 common users, it needs to change some settings. |
[root@dlp ~(keystone)]# openstack role list +----------------------------------+------------------+ | ID | Name | +----------------------------------+------------------+ | 4c700d9cf8e74d15939866751160b8e2 | CloudUser | | 50c665f9fef44e94859f3917fa5209d7 | reader | | 57f0601d9b9f4836b6f606c64e58b083 | heat_stack_owner | | bd7c20ef06864388806511e3c1f6f3a9 | heat_stack_user | | c8e2eb5f05d54f0292628e9304648c15 | member | | f7e97312fb04428bae7ff4506dde29dc | admin | +----------------------------------+------------------+[root@dlp ~(keystone)]# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | affa3a6446154e37adfd233c437bacc1 | service | | b9bf51c6436a4c5aa7a2df05688afb49 | admin | | f1f04d774d2141fb9acabd28d0e00c33 | hiroshima | +----------------------------------+-----------+[root@dlp ~(keystone)]# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 431cac9bf8244de39edbbf9bf69ef84c | admin | | 95da4d31df43419ebb1e495e5eb180bd | glance | | ddc826fcee8f4695a6af91e71add144f | nova | | d32e7f6fce6f4f639d72c8a8eabc7dd4 | placement | | fdf65d0b49ee4bd6a2713219139d5af9 | neutron | | e08c35de3b6746bd9518c97f7068a71e | serverworld | | 37eac0fbdeb346a0b37e8e48d977f4ae | cinder | | a43acdb98b314569b8a837784dda00a2 | heat | | c19fd0eabc8947478bd3539f2357cde1 | 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 th Node Neutron Server is running, change settings for Neutron [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, allowed common users can create stacks [cent@dlp ~(keystone)]$ openstack stack list +--------------------------------------+--------------+-----------------+----------------------+--------------+ | ID | Stack Name | Stack Status | Creation Time | Updated Time | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 6be4b981-816a-4c9e-987b-9327c6d97d52 | Sample-Stack | CREATE_COMPLETE | 2021-03-24T08:13:00Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+[cent@dlp ~(keystone)]$ openstack server list +--------------------------------------+----------------------+---------+------------------------------------+-----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+------------------------------------+-----------------+----------+ | 1b1cac4e-0796-4f35-a448-4b5a87ed94e1 | Heat_Deployed_Server | ACTIVE | private=192.168.100.37 | CentOS-Stream-8 | m1.small | +--------------------------------------+----------------------+---------+------------------------------------+-----------------+----------+ |
Sponsored Link |
|