OpenStack Zed : Heat 利用方法2022/10/10 |
OpenStack Orchestration Service(Heat)の利用方法です。
当例では以下のような環境を例に Orchestration サービスを設定しています。
------------+-----------------------------+-----------------------------+------------ | | | 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 Nginx | | Neutron Server | | Nova Compute | | Keystone httpd | | OVN-Northd | | Open vSwitch | | Glance Nova API | | Nginx iSCSI Target | | OVN Metadata Agent | | Cinder API | | Cinder Volume | | OVN-Controller | | | | Heat API/Engine | | | +-----------------------+ +-----------------------+ +-----------------------+ |
[1] | 構築した Heat サービスとテンプレートを利用してインスタンスをデプロイします。 作業は、どこでもよいですが、当例ではコントロールノード上で行います。 |
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 | +--------------------------------------+------------+--------+ | 126bc335-fc00-478d-b84a-a9e79eba2574 | Ubuntu2204 | active | +--------------------------------------+------------+--------+root@dlp ~(keystone)# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 394ec727-7e9a-473e-8068-45aa841a9ac2 | public | ea6cb6cb-74ed-4007-bd25-b3fb84111e84 | | 7336a271-bec9-4d33-8dc5-e9f3a9892ed7 | private | a454cf3e-fef5-46f6-8468-4a26cbd14983 | +--------------------------------------+---------+--------------------------------------+root@dlp ~(keystone)# Int_Net_ID=$(openstack network list | grep private | awk '{ print $2 }')
# サンプルテンプレートからインスタンス作成 root@dlp ~(keystone)# openstack stack create -t sample-stack.yml --parameter "ImageID=Ubuntu2204;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | 558f4398-183a-4351-9693-95d77b0817df | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2022-10-10T03:46:57Z | | updated_time | None | | stack_status | CREATE_IN_PROGRESS | | stack_status_reason | Stack CREATE started | +---------------------+--------------------------------------+ # しばらく待つとステータスがコンプリートになる root@dlp ~(keystone)# openstack stack list +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | ID | Stack Name | Project | Stack Status | Creation Time | Updated Time | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | 558f4398-183a-4351-9693-95d77b0817df | Sample-Stack | 231a529f51394426b07c56f2c5ec580e | CREATE_COMPLETE | 2022-10-10T03:46:57Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # テンプレートで指定したインスタンスが起動している root@dlp ~(keystone)# openstack server list +--------------------------------------+----------------------+--------+------------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+------------------------+------------+----------+ | 95fe8a79-8698-4e36-b9f1-3ea110926a93 | Heat_Deployed_Server | ACTIVE | private=192.168.100.12 | Ubuntu2204 | m1.small | +--------------------------------------+----------------------+--------+------------------------+------------+----------+ # 作成したインスタンスを削除する root@dlp ~(keystone)# openstack stack delete --yes Sample-Stack root@dlp ~(keystone)# openstack stack list |
[2] |
テンプレートの記述方法のガイドは公式サイトに記載されているので参考にしてください。
⇒ https://docs.openstack.org/heat/latest/template_guide/index.html |
[3] | 一般ユーザーでも Heat を利用したい場合は、Heat 用のロールに追加すれば OK です。 |
root@dlp ~(keystone)# openstack role list +----------------------------------+------------------+ | ID | Name | +----------------------------------+------------------+ | 1df48dad71a745849c2847a3b5ec1785 | reader | | 384ed6af259c4fa88083f811393f0567 | heat_stack_user | | 452c8bdf83534aba852b732c7a149096 | member | | 4dc68cf727eb44f0b69e905ff64f3a29 | heat_stack_owner | | 5b696b9d402f4545b4592aa3f7733c68 | CloudUser | | 5c0c4dc038b5441f9b64345ea113f3cb | admin | +----------------------------------+------------------+root@dlp ~(keystone)# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 231a529f51394426b07c56f2c5ec580e | admin | | 4dd1e1f6bac441ff9c77002c3ab4c58a | hiroshima | | ee51c09c765e4a4d958c2bcc4dbb5665 | service | +----------------------------------+-----------+root@dlp ~(keystone)# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 7c9dbb0cdc284113964d618b24cc722e | admin | | 0aef0c555a4f4cc885c80dd0eb4f7c72 | glance | | 4d912be26a4149d590dbfb7bc8b015fa | nova | | b3ad6ca00649400a8eae75d64a1c2181 | placement | | bcf45964c78c40fba4c125e31dee3721 | neutron | | 9345b7f4de21427abf31ad308cf952f8 | serverworld | | 3042ebda5502448097dd0bbbe3058812 | cinder | | 1bfd1646d0e04371a3c6199bc98d152f | heat | | b477de75cfbe4a5e863bc4d7ea1d2d5f | heat_domain_admin | +----------------------------------+-------------------+ # 例として [hiroshima] プロジェクトの [serverworld] ユーザーを [heat_stack_owner] ロールに追加 root@dlp ~(keystone)# openstack role add --project hiroshima --user serverworld heat_stack_owner
# 以上で一般ユーザーでも以下のようにスタックが作成できる ubuntu@dlp ~(keystone)$ openstack stack list +--------------------------------------+--------------+-----------------+----------------------+--------------+ | ID | Stack Name | Stack Status | Creation Time | Updated Time | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 7788d7b8-a6ad-4de1-b4e4-a7dc514e64d7 | Sample-Stack | CREATE_COMPLETE | 2022-10-10T03:52:32Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+ubuntu@dlp ~(keystone)$ openstack server list +--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+ | 0882b9a1-defa-4935-bd36-ada69c1c96e6 | Heat_Deployed_Server | ACTIVE | private=192.168.100.144 | Ubuntu2204 | m1.small | | a456ee32-b105-4c5e-8eae-ddccb48f913e | Ubuntu-2204 | SHUTOFF | private=10.0.0.228, 192.168.100.187 | Ubuntu2204 | m1.small | +--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+ |
Sponsored Link |
|