OpenStack Zed : Heat 利用方法2023/06/29 |
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 | +--------------------------------------+----------+--------+ | 3a660af6-3f41-4c0f-b2a8-55127dfc3c60 | Debian12 | active | +--------------------------------------+----------+--------+root@dlp ~(keystone)# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | ae5fdb1f-efb9-412b-9053-b81106c90336 | private | b3234f3f-b3e3-41d2-b3a4-ca3d4ec55d24 | | b9b8536b-0696-4a5b-af05-602587435c0a | public | 0129c597-e411-450e-a4f9-b387c68eddb3 | +--------------------------------------+---------+--------------------------------------+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=Debian12;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | c49bb959-915e-499a-b5f4-583172d24f36 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2023-06-29T05:43:36Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | c49bb959-915e-499a-b5f4-583172d24f36 | Sample-Stack | 757625ae78404e38a8cfdd7c6d262860 | CREATE_COMPLETE | 2023-06-29T05:43:36Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # テンプレートで指定したインスタンスが起動している root@dlp ~(keystone)# openstack server list +--------------------------------------+----------------------+--------+-------------------------+----------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+-------------------------+----------+----------+ | 34ab285f-b8a6-4f4f-9180-671c06dcd6c2 | Heat_Deployed_Server | ACTIVE | private=192.168.100.244 | Debian12 | 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 | +----------------------------------+------------------+ | 109c6488ef4347d681ba691f8ac97a6b | member | | 6055174790cd4797ae3671b38d935c53 | service | | 81f2687109a245b580690b6e8f9095db | heat_stack_owner | | 82699442db4e4edea2fb7986340b5ab4 | admin | | db9927603e564f94b2f0a4312d1a63da | heat_stack_user | | eb3d0d5b10cd456093463a2c12e41b82 | reader | +----------------------------------+------------------+root@dlp ~(keystone)# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 1c2f5dc8c4f9494fbaaa4217c8e3585a | hiroshima | | 757625ae78404e38a8cfdd7c6d262860 | admin | | d8b09d86ed7743039f92b2e542ea26c1 | service | +----------------------------------+-----------+root@dlp ~(keystone)# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | a45313c73c4842d7b5ba90f56be73de2 | admin | | b166b462bd214a34b99e079c806bef55 | glance | | 9fb0ad5b33f9492594f4139f5b428dab | nova | | 5db174d072dd4bcc90d34d7b0c4f0e36 | placement | | 1b4f2549a8ee462d909185b6a321e265 | neutron | | de51d5f0ee2c485885877d21f5b424e0 | serverworld | | 5b1712badfdb4824927488f7882cc7ca | cinder | | f485fdd327064f56ac0182c3b084525b | heat | | 65993a5e1fe0476486e82091276c2827 | heat_domain_admin | +----------------------------------+-------------------+ # 例として [hiroshima] プロジェクトの [serverworld] ユーザーを [heat_stack_owner] ロールに追加 root@dlp ~(keystone)# openstack role add --project hiroshima --user serverworld heat_stack_owner
# 以上で一般ユーザーでも以下のようにスタックが作成できる debian@dlp ~(keystone)$ openstack stack list +--------------------------------------+--------------+-----------------+----------------------+--------------+ | ID | Stack Name | Stack Status | Creation Time | Updated Time | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 9df1c577-abb5-4fa9-ad5e-d3869ed178a3 | Sample-Stack | CREATE_COMPLETE | 2023-06-29T05:46:45Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+debian@dlp ~(keystone)$ openstack server list +--------------------------------------+----------------------+---------+------------------------------------+----------+-----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+------------------------------------+----------+-----------+ | e1402488-fbab-4d48-8bb1-957f0691a749 | Heat_Deployed_Server | ACTIVE | private=192.168.100.25 | Debian12 | m1.small | | c3a4a792-a7ac-41bd-8c93-7fd162016f22 | Debian-12 | SHUTOFF | private=10.0.0.241, 192.168.100.66 | Debian12 | m1.medium | +--------------------------------------+----------------------+---------+------------------------------------+----------+-----------+ |
Sponsored Link |