OpenStack Yoga : Heat 利用方法2022/06/10 |
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 httpd | | Neutron Server | | Nova Compute | | Keystone Glance | | OVN-Northd | | Open vSwitch | | Nova API Cinder API | | Cinder Volume | | OVN Metadata Agent | | | | Heat API/Engine | | OVN-Controller | +-----------------------+ +-----------------------+ +-----------------------+ |
[1] | 構築した Heat サービスとテンプレートを利用してインスタンスをデプロイします。 作業場所は、どこでもよいですが、当例ではコントロールノード上で行います。 |
[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-yoga,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 | +--------------------------------------+----------------+--------+ | 1044ab46-c42b-4cf6-ab1f-aaeb011fb3b9 | CentOS-Stream9 | active | +--------------------------------------+----------------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 9669b364-5e91-4858-bff1-437a23be347b | public | 50ab40e2-c1ff-4371-a829-bbc228ddd16f | | c4ede804-96e1-4b1b-bf1b-341f752065c0 | private | 80a576b7-55e6-4d3b-86d9-26bb0c4e7d57 | +--------------------------------------+---------+--------------------------------------+[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 | a3a3f179-8cac-4ef2-98a1-b3c27bc7d460 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2022-06-10T04:26:09Z | | 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ | a3a3f179-8cac-4ef2-98a1-b3c27bc7d460 | Sample-Stack | 9c8b7457e8db4cbc995a767706804b70 | CREATE_COMPLETE | 2022-06-10T04:26:09Z | None | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # テンプレートで指定したインスタンスが起動している [root@dlp ~(keystone)]# openstack server list +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+--------+-------------------------+----------------+----------+ | cb651776-34a5-45cc-bcb3-e0113e3facf4 | Heat_Deployed_Server | ACTIVE | private=192.168.100.172 | 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 を利用したい場合は、設定変更が必要です。 |
[root@dlp ~(keystone)]# openstack role list +----------------------------------+------------------+ | ID | Name | +----------------------------------+------------------+ | 16412daf1fb0451bbc38119fbe7fdd5e | heat_stack_owner | | 2ed73129635949579e071bd01563ba4f | admin | | 8c46c138d04543a19500eb30170adc5a | reader | | ad273121353f477db37e30d683deb0d4 | CloudUser | | b5fd8fd9ddf94d19911472d768ef9f2c | heat_stack_user | | e5a78e58eab343b5ad161b837cb04677 | member | +----------------------------------+------------------+[root@dlp ~(keystone)]# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 0f2625947bf0433a9519ba8a29434bdf | service | | 911e5ff7686741c782d6acc6d7155db1 | hiroshima | | 9c8b7457e8db4cbc995a767706804b70 | admin | +----------------------------------+-----------+[root@dlp ~(keystone)]# openstack user list +----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | e4fc506f9a584389af582670c86de058 | admin | | b099e64a43d444a9b5cf82bc4c329916 | glance | | 9f98c3e8a10d475eaad4e3c04348ac24 | nova | | 54ec5ec9ba2f43008752358ba6767280 | placement | | c32241d8cb664f50bda4db9a74d7e45d | neutron | | 1ff4591a7f8140fcad38fd9f606a66a6 | serverworld | | 6821aaccc3be4a78b86c78ac883e8ade | cinder | | 25c0ed34e42349f3bc82051e0a3b4279 | heat | | fb08d19137674b32bceb76fbc70e03f5 | heat_domain_admin | +----------------------------------+-------------------+ # 例として [hiroshima] プロジェクトの [serverworld] ユーザーを [heat_stack_owner] ロールに追加 [root@dlp ~(keystone)]# openstack role add --project hiroshima --user serverworld heat_stack_owner
# 以下の内容で新規作成 # 管理者のみに許可されている権限を設定なしで上書きする { "create_port:fixed_ips:subnet_id": "", "create_port:allowed_address_pairs": "", "create_port:allowed_address_pairs:ip_address": "", }
[root@network ~]# systemctl restart neutron-server
# 以上で一般ユーザーでも以下のようにスタックが作成できる [cent@dlp ~(keystone)]$ openstack stack list +--------------------------------------+--------------+-----------------+----------------------+--------------+ | ID | Stack Name | Stack Status | Creation Time | Updated Time | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 2d80b919-2ca6-43c9-be70-67409c4c2ce9 | Sample-Stack | CREATE_COMPLETE | 2022-06-10T04:31:18Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+[cent@dlp ~(keystone)]$ openstack server list +--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+ | 810cf823-db9f-48d7-8016-75f39b66a890 | Heat_Deployed_Server | ACTIVE | private=192.168.100.13 | CentOS-Stream9 | m1.small | | 25ef320e-b16e-4085-96ef-af7fa0d33cfb | CentOS-St9 | SHUTOFF | private=10.0.0.242, 192.168.100.214 | CentOS-Stream9 | m1.small | +--------------------------------------+----------------------+---------+-------------------------------------+----------------+----------+ |
Sponsored Link |