Ubuntu 24.04
Sponsored Link

OpenStack Caracal : Heat 利用方法2024/05/22

 

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
# テスト用テンプレート作成

root@dlp ~(keystone)#
vi sample-stack.yml
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 |
+--------------------------------------+------------+--------+
| 7620a182-99f2-4132-9c6e-4b2da962b241 | Ubuntu2404 | active |
+--------------------------------------+------------+--------+

root@dlp ~(keystone)#
openstack network list

+---------------------------------+---------+----------------------------------+
| ID                              | Name    | Subnets                          |
+---------------------------------+---------+----------------------------------+
| 5e99fe3a-c28a-47b3-ae5f-        | public  | 5f767674-473e-402c-ba60-         |
| 504fa513709b                    |         | cc6d6b9e5513                     |
| 78a330d7-074f-491d-a820-        | private | 5ac5f7dc-c275-48a1-aaac-         |
| 2b5e87f5602f                    |         | 745dd2f61ea7                     |
+---------------------------------+---------+----------------------------------+

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                  | 3d7f5aa5-eba7-4801-9d12-a1f3533f9695 |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2024-05-22T01:42:25Z                 |
| 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 |
+------------+------------+------------+--------------+---------------+--------------+
| 3d7f5aa5-  | Sample-    | 9c5145f76f | CREATE_COMPL | 2024-05-      | None         |
| eba7-4801- | Stack      | d84324bdd2 | ETE          | 22T01:42:25Z  |              |
| 9d12-      |            | b1b61658a2 |              |               |              |
| a1f3533f96 |            | 82         |              |               |              |
| 95         |            |            |              |               |              |
+------------+------------+------------+--------------+---------------+--------------+

# テンプレートで指定したインスタンスが起動している

root@dlp ~(keystone)#
openstack server list

+--------------+--------------+--------+---------------+------------+----------+
| ID           | Name         | Status | Networks      | Image      | Flavor   |
+--------------+--------------+--------+---------------+------------+----------+
| 2f4a92be-    | Heat_Deploye | ACTIVE | private=192.1 | Ubuntu2404 | m1.small |
| 2734-42b1-   | d_Server     |        | 68.100.81     |            |          |
| ba4e-        |              |        |               |            |          |
| ac92aa628e04 |              |        |               |            |          |
+--------------+--------------+--------+---------------+------------+----------+

# 作成したインスタンスを削除する

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             |
+----------------------------------+------------------+
| 434c72643a134d18afd1d12094cfc75d | service          |
| 5afd228854f24746b11c26350784938a | heat_stack_owner |
| a15f53c1498a442281b01059ff6c9e0f | heat_stack_user  |
| b5c98a36bb6e4258a76a76bc96727fac | reader           |
| d7e77a716fd34ac2b6e8a91c19d5d91d | member           |
| d8f785820bf545f897e1fb2f35adefca | manager          |
| eccdad43835c44ad80be889f658236f3 | admin            |
+----------------------------------+------------------+

root@dlp ~(keystone)#
openstack project list

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 18ede7365bdc430093e8fd4a90f77369 | hiroshima |
| 9c5145f76fd84324bdd2b1b61658a282 | admin     |
| ab9749e59bdb48e4807a18abb83c9f99 | service   |
+----------------------------------+-----------+

root@dlp ~(keystone)#
openstack user list

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| 3293956ed49545e7b8b45fffa0335e24 | admin             |
| ef82743092ad4032a6c9cbd1c655dab6 | glance            |
| 615a0611270e4887935501977ff7dff0 | nova              |
| bf7932c4546a46f89b7133ff11c591c3 | placement         |
| e83aa70b68ba43528e48067d60c20a4b | neutron           |
| b9371d015e0d43dca74f29161448ffd2 | serverworld       |
| 4def6f94581c43a3b2627416608a42b9 | cinder            |
| 089ecbb2dcaa421aa549bd8efb9f03f2 | heat              |
| cf935777627845dead14b4a5d7576f3a | 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 |
+---------------+--------------+---------------+----------------+--------------+
| abe4d9a2-     | Sample-Stack | CREATE_COMPLE | 2024-05-       | None         |
| 547e-464e-    |              | TE            | 22T01:46:14Z   |              |
| b688-         |              |               |                |              |
| 4d800475143d  |              |               |                |              |
+---------------+--------------+---------------+----------------+--------------+

ubuntu@dlp ~(keystone)$
openstack server list

+--------------+--------------+---------+--------------+------------+----------+
| ID           | Name         | Status  | Networks     | Image      | Flavor   |
+--------------+--------------+---------+--------------+------------+----------+
| 4b9c9101-    | Heat_Deploye | ACTIVE  | private=192. | Ubuntu2404 | m1.small |
| 2c33-4eea-   | d_Server     |         | 168.100.195  |            |          |
| 9184-        |              |         |              |            |          |
| 25fbe0ebff88 |              |         |              |            |          |
| 7fbc24c1-    | Ubuntu-2404  | SHUTOFF | private=10.0 | Ubuntu2404 | m1.small |
| c0d1-43d6-   |              |         | .0.208, 192. |            |          |
| 87aa-        |              |         | 168.100.130  |            |          |
| 68df83597b57 |              |         |              |            |          |
+--------------+--------------+---------+--------------+------------+----------+
関連コンテンツ