OpenStack Caracal : Heat 利用方法2024/04/09 |
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 | | Neutron L2/L3 Agent | | Libvirt | | Memcached Nginx | | Neutron Metadata | | Nova Compute | | Keystone httpd | | Open vSwitch | | Neutron L2 Agent | | Glance Nova API | | iSCSI Target | | Open vSwitch | | Neutron Server | | Cinder Volume | | | | Neutron Metadata | | Heat API/Engine | | | | Cinder API | | | | | +-----------------------+ +-----------------------+ +-----------------------+ |
[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 | +--------------------------------------+------------+--------+ | 76820d6f-918b-44ac-ad2f-c8075456ff45 | Ubuntu2204 | active | +--------------------------------------+------------+--------+root@dlp ~(keystone)# openstack network list +---------------------------------+---------+----------------------------------+ | ID | Name | Subnets | +---------------------------------+---------+----------------------------------+ | 24288203-5512-40c5-8bcb- | public | 0b39a7b6-3b03-4704-ba32- | | aed6dffc2bc1 | | 89e5894bad2c | | b28ad879-8bbf-40fe-b2fb- | private | 42dd9fb5-a0f2-4556-b896- | | af772cf88a8a | | 6257cb5119f6 | +---------------------------------+---------+----------------------------------+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 | bc9c570b-2ff9-4650-8fb4-72b6e5ba49f2 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2024-04-09T06:58:26Z | | 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 | +------------+------------+------------+--------------+---------------+--------------+ | bc9c570b- | Sample- | 62980715ee | CREATE_COMPL | 2024-04- | None | | 2ff9-4650- | Stack | 6d434eaf4e | ETE | 09T06:58:26Z | | | 8fb4- | | fddd9b63e9 | | | | | 72b6e5ba49 | | d6 | | | | | f2 | | | | | | +------------+------------+------------+--------------+---------------+--------------+ # テンプレートで指定したインスタンスが起動している root@dlp ~(keystone)# openstack server list +--------------+--------------+--------+---------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+--------------+--------+---------------+------------+----------+ | bf1c1167- | Heat_Deploye | ACTIVE | private=192.1 | Ubuntu2204 | m1.small | | 184d-403d- | d_Server | | 68.100.84 | | | | b468- | | | | | | | aa3c07c28af3 | | | | | | +--------------+--------------+--------+---------------+------------+----------+ # 作成したインスタンスを削除する 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 | +----------------------------------+------------------+ | 3d69f0474abe48869999014caae40558 | admin | | 44bca5dd1676498996c6ca78f2b61cd2 | service | | 4cb545b66c61411f8c75d65708d650e9 | reader | | 68ac49b978524b0a99060b177ea96f60 | manager | | 6b2003ce3c3241aaaf6a70ea3e814de7 | member | | c563d10b879d48b5bf9013515f0a410f | heat_stack_user | | cd14b829a842488188299462ff4dd37e | heat_stack_owner | +----------------------------------+------------------+root@dlp ~(keystone)# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 2bcdd2fecf1d4a8c8faf87f1232cf365 | hiroshima | | 62980715ee6d434eaf4efddd9b63e9d6 | admin | | c9a28e6f0f794ccf889c115bb9c2872c | service | +----------------------------------+-----------+root@dlp ~(keystone)# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 27a667fb6dd84abf950add9f36ad72ae | admin | | 98cc3b3090fa4f2683b0fd77ad849fe4 | glance | | 14118344ffac4cd180e77dedd181fa53 | nova | | 2bdae31834f3416a8eab803b5f25ef82 | placement | | bb6b7624bc6b45bdae1125db005133ff | neutron | | e682843492a44937b745ef945bfacf70 | serverworld | | 0f0b38d9c3a5423ebbdf92d26fcf3ddf | cinder | | a57f5ef4320d4944a6cc7e6372ada879 | heat | | 34ad5075ff2b4ef5a5f51e7278eacd04 | 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 | +---------------+--------------+---------------+----------------+--------------+ | b89ffe65- | Sample-Stack | CREATE_COMPLE | 2024-04- | None | | 150a-44fe- | | TE | 09T07:01:20Z | | | 8dfd- | | | | | | 23d2726c4cfb | | | | | +---------------+--------------+---------------+----------------+--------------+ubuntu@dlp ~(keystone)$ openstack server list +--------------+--------------+---------+--------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+--------------+---------+--------------+------------+----------+ | c41e770c- | Heat_Deploye | ACTIVE | private=192. | Ubuntu2204 | m1.small | | ec24-4cdf-bc | d_Server | | 168.100.78 | | | | 5c- | | | | | | | 86af5897344a | | | | | | | e7feb65c- | Ubuntu-2204 | SHUTOFF | private=10.0 | Ubuntu2204 | m1.small | | 1482-48a9- | | | .0.250, 192. | | | | 9d45- | | | 168.100.188 | | | | e74196a5ea92 | | | | | | +--------------+--------------+---------+--------------+------------+----------+ |
Sponsored Link |
|