OpenStack Yoga : How to use Heat2022/06/01 |
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 Controle Node. |
[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-yoga,powertools,epel -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 | +--------------------------------------+-----------------+--------+ | 7be5b7ab-36e8-43c7-95dd-34b4139a0e44 | CentOS-Stream-8 | active | +--------------------------------------+-----------------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 0c96d581-95f3-4e72-9626-d0a94407d0ec | public | e20328ce-a24a-4804-be39-88f18800526f | | 0f0af4c7-f2d1-4c13-b30c-4619ff33db0c | private | 748c0a25-c6d8-48fd-829e-8b15783b7f8a | +--------------------------------------+---------+--------------------------------------+[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 | 2f5a9033-cf2f-41e6-844a-3fd56a132d90 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2022-06-01T05:08:54Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | 2f5a9033-cf2f-41e6-844a-3fd56a132d90 | Sample-Stack | 0609d3b3b398456187fb705ec9224c4a | CREATE_COMPLETE | 2022-06-01T05:08:54Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template [root@dlp ~(keystone)]# openstack server list +--------------------------------------+----------------------+--------+------------------------+-----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+------------------------+-----------------+----------+ | 20182739-d2d9-4084-85c6-237b43f3cb42 | Heat_Deployed_Server | ACTIVE | private=192.168.100.84 | 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 | +----------------------------------+------------------+ | 092c3c3e1ca74f12957c01bbbdbacf35 | CloudUser | | 1bc22cc802be4976b955668b2da25052 | heat_stack_owner | | 4c9e739222cb47daafb8e8184e380ae4 | admin | | 6765ea4d8ea64eae8c5f24dd0d9fa4d4 | member | | 6d521d08fa1b4abcbe709ee858e80cb7 | heat_stack_user | | 99938d7dbeb747f3a803c81d7b0d83e0 | reader | +----------------------------------+------------------+[root@dlp ~(keystone)]# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 0609d3b3b398456187fb705ec9224c4a | admin | | 3d85d1e79d654b3dade01eb5bfbf0679 | hiroshima | | 8787527217494c6a87dd5a3b68dce1ef | service | +----------------------------------+-----------+[root@dlp ~(keystone)]# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 63596ba65a1b45d5890f6407152692c7 | admin | | 2aafe40cdb944b618294bcc2310cfdf9 | glance | | 4e1fe87e017d476283845f55e12ae058 | nova | | 3ac1fb9042e24d2a92e524f4f16bc154 | placement | | beb862be39184dd89a3faa71b930181e | neutron | | ed0bc393ae81411fa1db0828e1d5e160 | serverworld | | 8f0b83f989df495a82deea1ca315acb5 | cinder | | b612f4de926740cd887f5335bc114fbf | heat | | bbe9ed86fec848428e978fea21c40278 | 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 | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 9272cdaa-141d-47e2-a1fa-193524cdaea7 | Sample-Stack | CREATE_COMPLETE | 2022-06-01T05:16:07Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+[cent@dlp ~(keystone)]$ openstack server list +--------------------------------------+----------------------+---------+-------------------------------------+-----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+-------------------------------------+-----------------+----------+ | d1f022ea-fa60-4ac8-aba4-b1ba1c726920 | Heat_Deployed_Server | ACTIVE | private=192.168.100.207 | CentOS-Stream-8 | m1.small | | fa3a20c0-f0f4-46eb-b63f-69abba312d03 | CentOS-St8 | SHUTOFF | private=10.0.0.251, 192.168.100.140 | CentOS-Stream-8 | m1.small | +--------------------------------------+----------------------+---------+-------------------------------------+-----------------+----------+ |
Sponsored Link |