OpenStack Zed : Heat 利用方法2022/11/11 |
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)]#
dnf --enablerepo=centos-openstack-zed,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 | +--------------------------------------+----------------+--------+ | 8367cc21-61f4-480b-8d03-90c057c7a7cf | CentOS-Stream9 | active | +--------------------------------------+----------------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 004ca400-3d79-4c1b-b8fb-bba1e273000e | public | 80213093-ac95-469a-b4d9-8c6adc93cfe1 | | c9c79a1d-136e-4036-8fe0-eaac79f05f5d | private | 85e66c6a-66eb-490f-a4fa-e21f91678c89 | +--------------------------------------+---------+--------------------------------------+[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=CentOS-Stream9;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | 39417140-05b9-47b2-b92d-40876d5a1144 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2022-11-11T00:29:01Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | 39417140-05b9-47b2-b92d-40876d5a1144 | Sample-Stack | 939974d6fc8e400eb01f7dd749935ea3 | CREATE_COMPLETE | 2022-11-11T00:29:01Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # テンプレートで指定したインスタンスが起動している [root@dlp ~(keystone)]# openstack server list +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | 55681685-50f6-4252-a587-dee173e91129 | Heat_Deployed_Server | ACTIVE | private=192.168.100.243 | CentOS-Stream9 | m1.small | +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ # 作成したインスタンスを削除する [root@dlp ~(keystone)]# openstack stack delete --yes Sample-Stack
[root@dlp ~(keystone)]#
[root@dlp ~(keystone)]# openstack stack list openstack server list |
[2] |
テンプレートの記述方法のガイドは公式サイトに記載されているので参考にしてください。
⇒ https://docs.openstack.org/heat/latest/template_guide/index.html |
[3] | 一般ユーザーでも Heat を利用したい場合は、Heat 用のロールに追加すれば OK です。 |
[root@dlp ~(keystone)]# openstack role list +----------------------------------+------------------+ | ID | Name | +----------------------------------+------------------+ | 075291ce7c66499ea099a012a92f6695 | admin | | 1ace023940044b34b5a442eb38e97635 | heat_stack_owner | | 1c38efda26774c358fabbdfed25547ae | reader | | 245b582c47d744c1a6f706898534900a | CloudUser | | ae93621edfd4441096d4eb1b1e4be035 | heat_stack_user | | d0f53ed114fc4ed1b56679ba0b0ef33d | member | +----------------------------------+------------------+[root@dlp ~(keystone)]# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 28b6e37c787240e4a975d3614821cc71 | hiroshima | | 62f531f4d2934e75b8d7f11cd7d53be3 | service | | 939974d6fc8e400eb01f7dd749935ea3 | admin | +----------------------------------+-----------+[root@dlp ~(keystone)]# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | f00e5072d7d6488f935ea680256af89c | admin | | 78009f5643d240da9996dff0aee5cc37 | glance | | 7ed52b257a47436389a60aef689d20f0 | nova | | 2080b84b7e304486b33365a447963bc1 | placement | | 6f4af63a84f944f3a7a0c018ef64a4a1 | neutron | | 9e8824a151c949ad9105535ead452501 | serverworld | | 42de8b3de0c74f3e9f1622c89fc1a178 | cinder | | 03b59cb43c8547d4bf0a055dd9edd7a8 | heat | | e8c47aafd9324805b90b52f963dc6cad | heat_domain_admin | +----------------------------------+-------------------+ # 例として [hiroshima] プロジェクトの [serverworld] ユーザーを [heat_stack_owner] ロールに追加 [root@dlp ~(keystone)]# openstack role add --project hiroshima --user serverworld heat_stack_owner
# 以上で一般ユーザーでも以下のようにスタックが作成できる [cent@dlp ~(keystone)]$ openstack stack list +--------------------------------------+--------------+-----------------+----------------------+--------------+ | ID | Stack Name | Stack Status | Creation Time | Updated Time | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | bdd82a73-c300-4e92-b6dc-4a33bcadd0ad | Sample-Stack | CREATE_COMPLETE | 2022-11-11T00:33:47Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+[cent@dlp ~(keystone)]$ openstack server list +--------------------------------------+----------------------+---------+------------------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+------------------------------------+----------------+----------+ | 9198ab3c-be9d-4a67-8818-9ceb111ffa41 | Heat_Deployed_Server | ACTIVE | private=192.168.100.176 | CentOS-Stream9 | m1.small | | 158685ed-8159-4aad-a294-3227b427f7e1 | CentOS-St9 | SHUTOFF | private=10.0.0.218, 192.168.100.75 | CentOS-Stream9 | m1.small | +--------------------------------------+----------------------+---------+------------------------------------+----------------+----------+ |
Sponsored Link |
|