OpenStack Dalmatian : Heat 利用方法2024/10/14 |
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 | +--------------------------------------+------------+--------+ | a9d10f1d-d836-424d-8117-ff3fc8c5e966 | Ubuntu2404 | active | +--------------------------------------+------------+--------+root@dlp ~(keystone)# openstack network list +---------------------------------+---------+----------------------------------+ | ID | Name | Subnets | +---------------------------------+---------+----------------------------------+ | 2da36a04-0d3e-4de8-9be8- | private | bc45dd3e-0b15-42ca-a37b- | | a2972c15bbe4 | | 94f2feaf341e | | ce38ba4f-6066-4e93-ae59- | public | 22837749-299e-4323-bfc3- | | de238fb6ed08 | | 3120c8c2d635 | +---------------------------------+---------+----------------------------------+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=Ubuntu2404;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | af3858c8-e170-415d-812b-e82209f0da8c | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2024-10-14T01:13:35Z | | 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 | +------------+------------+------------+--------------+---------------+--------------+ | af3858c8- | Sample- | 7b2284a868 | CREATE_COMPL | 2024-10- | None | | e170-415d- | Stack | dd4b119b40 | ETE | 14T01:13:35Z | | | 812b- | | 0ad76ae20f | | | | | e82209f0da | | de | | | | | 8c | | | | | | +------------+------------+------------+--------------+---------------+--------------+ # テンプレートで指定したインスタンスが起動している root@dlp ~(keystone)# openstack server list +--------------+--------------+--------+---------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+--------------+--------+---------------+------------+----------+ | 8950466f- | Heat_Deploye | ACTIVE | private=192.1 | Ubuntu2404 | m1.small | | 650a-43f6- | d_Server | | 68.100.92 | | | | 8cec- | | | | | | | 51123db9d7c7 | | | | | | +--------------+--------------+--------+---------------+------------+----------+ # 作成したインスタンスを削除する 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 | +----------------------------------+------------------+ | 0c0e56e84a0741ffa6db6a21c8fefadd | member | | 777f0e020c0c45a5adc2ad3ab77f723f | service | | 85e48e4b84984b909e5b2b5e6edba766 | admin | | 8ac6e4f5c0d749d3beb6cdadcad1e321 | manager | | bc5f4baae4fa4e7080c66e8ba1da1660 | reader | | c03aacb803f6431fb603f22599527c79 | heat_stack_user | | e67d540be8b94bc19b2aaec739ddc232 | heat_stack_owner | +----------------------------------+------------------+root@dlp ~(keystone)# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 0b61bc880cd64b67946dd6352a138e30 | service | | 7b2284a868dd4b119b400ad76ae20fde | admin | | 84e315c8d65e4b3cb33aaf69c9eed0c3 | hiroshima | +----------------------------------+-----------+root@dlp ~(keystone)# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 76a9724ed247448d9c71a2ea67713063 | admin | | 2acfc92941ca4980964dc80ae4e1a1f4 | glance | | e6d0780b6c4844198fdc3d16fdd0f313 | nova | | 6c45736ec2b54565888b47a22be9fa1c | placement | | 73e92a3ca6bb4a5ba58d8a0a4bce449a | neutron | | d97d1aef1b234c469ad3757bcd51dfa4 | serverworld | | 461d084b1d134ccb8d4bf992a7369c9c | cinder | | 5c584c6f80b3425baa2818fead5582c9 | heat | | a9055cb90a6f4da19e1ca0ce8a657ca8 | 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 | +---------------+--------------+---------------+----------------+--------------+ | 65925254- | Sample-Stack | CREATE_COMPLE | 2024-10- | None | | a1ab-4819- | | TE | 14T01:17:55Z | | | b414- | | | | | | 7a0dc3df13ff | | | | | +---------------+--------------+---------------+----------------+--------------+ubuntu@dlp ~(keystone)$ openstack server list +--------------+--------------+---------+--------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------+--------------+---------+--------------+------------+----------+ | a413d26a- | Heat_Deploye | ACTIVE | private=192. | Ubuntu2404 | m1.small | | e62d-4ff0- | d_Server | | 168.100.180 | | | | 99ad- | | | | | | | 30ffcd2bcfc7 | | | | | | | b8fcec95- | Ubuntu-2404 | SHUTOFF | private=10.0 | Ubuntu2404 | m1.small | | d25f-4f1f- | | | .0.203, 192. | | | | 95ec- | | | 168.100.99 | | | | 91ee1e0e66b1 | | | | | | +--------------+--------------+---------+--------------+------------+----------+ |
Sponsored Link |