OpenStack Dalmatian : Heat 利用方法2024/10/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-dalmatian,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 | +--------------------------------------+----------------+--------+ | 75e0d976-4075-4488-8f26-87d4a50aebe9 | CentOS-Stream9 | active | +--------------------------------------+----------------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 7302c07e-c543-4a85-a955-d6cc8a4e4011 | public | 8fbc394a-e821-47d8-8efc-d5f7c7db0ff8 | | aa200aa9-ddb2-4d89-aa37-ce3e3a939421 | private | dfb0949d-d775-4c17-9b07-b01ac7d71aac | +--------------------------------------+---------+--------------------------------------+[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 | 5b7ac3eb-ee41-49aa-a6e2-23b8a1a5e300 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2024-10-11T06:48:00Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | 5b7ac3eb-ee41-49aa-a6e2-23b8a1a5e300 | Sample-Stack | b19d04cd37254937a4eaebcd0f0f0a43 | CREATE_COMPLETE | 2024-10-11T06:48:00Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # テンプレートで指定したインスタンスが起動している [root@dlp ~(keystone)]# openstack server list +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | 067b09be-049b-46bb-ba1f-a15e8a731de4 | Heat_Deployed_Server | ACTIVE | private=192.168.100.232 | 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 | +----------------------------------+------------------+ | 1d531758bc864a3cbb0d85e701aebbbb | heat_stack_user | | 325e5c0b45184b82a671d341b19de2aa | heat_stack_owner | | 4cbffcb8460a472e9f248e8536b6b254 | admin | | 81e7f75a8ff44892b9a7c66b1bfce8ed | service | | 842b4194a02f4ae2849a88d20c9240b1 | member | | c29749ff7b354c4eb175e6d22a99bc14 | manager | | ec7c81493ae4438fb9ef1b6f333302c7 | reader | +----------------------------------+------------------+[root@dlp ~(keystone)]# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 756e2b4937c44d3991028e294f92d89a | hiroshima | | aff8e7e402dc4d9e849bbe0e34fa4538 | service | | b19d04cd37254937a4eaebcd0f0f0a43 | admin | +----------------------------------+-----------+[root@dlp ~(keystone)]# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 2848dbbdd1714726b5b9a105c1382618 | admin | | acc884feccc14373a1f9fc8dda806eee | glance | | b46ff6a5849c4e90ae4eb0aa4b43e098 | nova | | f18f2b8163d44d15beaf9e491bc399f6 | placement | | bed4478c6b3446338b95d41979485ee3 | neutron | | 19c7530debb54eb0bfe6dc47aae3df32 | serverworld | | ddd4329358524a38a69e0dfe3effe87e | cinder | | 99a4af2f51c34fdab3299f660ef1be2d | heat | | 3be7a60d447b46f58769630abac753ae | 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 | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 1aed7f14-f157-467a-8062-032e1f639c56 | Sample-Stack | CREATE_COMPLETE | 2024-10-11T06:51:01Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+[cent@dlp ~(keystone)]$ openstack server list +--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+ | 57e00e0f-5b81-4ca9-9e5f-59e966eeb63f | Heat_Deployed_Server | ACTIVE | private=192.168.100.146 | CentOS-Stream9 | m1.small | | 3d753408-6705-4cbf-acd8-2e09d975b973 | CentOS-St9 | SHUTOFF | private=10.0.0.206, 192.168.100.103 | CentOS-Stream9 | m1.small | +--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+ |
Sponsored Link |