OpenStack Yoga : How to use Heat2022/06/10 |
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)]#
dnf --enablerepo=centos-openstack-yoga,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 | +--------------------------------------+----------------+--------+ | 1044ab46-c42b-4cf6-ab1f-aaeb011fb3b9 | CentOS-Stream9 | active | +--------------------------------------+----------------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 9669b364-5e91-4858-bff1-437a23be347b | public | 50ab40e2-c1ff-4371-a829-bbc228ddd16f | | c4ede804-96e1-4b1b-bf1b-341f752065c0 | private | 80a576b7-55e6-4d3b-86d9-26bb0c4e7d57 | +--------------------------------------+---------+--------------------------------------+[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 | a3a3f179-8cac-4ef2-98a1-b3c27bc7d460 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2022-06-10T04:26:09Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | a3a3f179-8cac-4ef2-98a1-b3c27bc7d460 | Sample-Stack | 9c8b7457e8db4cbc995a767706804b70 | CREATE_COMPLETE | 2022-06-10T04:26:09Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template [root@dlp ~(keystone)]# openstack server list +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | cb651776-34a5-45cc-bcb3-e0113e3facf4 | Heat_Deployed_Server | ACTIVE | private=192.168.100.172 | 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 common users, it needs to change some settings. |
[root@dlp ~(keystone)]# openstack role list +----------------------------------+------------------+ | ID | Name | +----------------------------------+------------------+ | 16412daf1fb0451bbc38119fbe7fdd5e | heat_stack_owner | | 2ed73129635949579e071bd01563ba4f | admin | | 8c46c138d04543a19500eb30170adc5a | reader | | ad273121353f477db37e30d683deb0d4 | CloudUser | | b5fd8fd9ddf94d19911472d768ef9f2c | heat_stack_user | | e5a78e58eab343b5ad161b837cb04677 | member | +----------------------------------+------------------+[root@dlp ~(keystone)]# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 0f2625947bf0433a9519ba8a29434bdf | service | | 911e5ff7686741c782d6acc6d7155db1 | hiroshima | | 9c8b7457e8db4cbc995a767706804b70 | admin | +----------------------------------+-----------+[root@dlp ~(keystone)]# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | e4fc506f9a584389af582670c86de058 | admin | | b099e64a43d444a9b5cf82bc4c329916 | glance | | 9f98c3e8a10d475eaad4e3c04348ac24 | nova | | 54ec5ec9ba2f43008752358ba6767280 | placement | | c32241d8cb664f50bda4db9a74d7e45d | neutron | | 1ff4591a7f8140fcad38fd9f606a66a6 | serverworld | | 6821aaccc3be4a78b86c78ac883e8ade | cinder | | 25c0ed34e42349f3bc82051e0a3b4279 | heat | | fb08d19137674b32bceb76fbc70e03f5 | 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 | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 2d80b919-2ca6-43c9-be70-67409c4c2ce9 | Sample-Stack | CREATE_COMPLETE | 2022-06-10T04:31:18Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+[cent@dlp ~(keystone)]$ openstack server list +--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+ | 810cf823-db9f-48d7-8016-75f39b66a890 | Heat_Deployed_Server | ACTIVE | private=192.168.100.13 | CentOS-Stream9 | m1.small | | 25ef320e-b16e-4085-96ef-af7fa0d33cfb | CentOS-St9 | SHUTOFF | private=10.0.0.242, 192.168.100.214 | CentOS-Stream9 | m1.small | +--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+ |
Sponsored Link |