Ubuntu 20.04
Sponsored Link

OpenStack Xena : Heat 利用方法2021/10/08

 
OpenStack Orchestration Service(Heat)の利用方法です。
当例では以下のような環境を例に Orchestration サービスを設定しています。
------------+---------------------------+---------------------------+------------
            |                           |                           |
        eth0|10.0.0.30              eth0|10.0.0.50              eth0|10.0.0.51
+-----------+-----------+   +-----------+-----------+   +-----------+-----------+
|    [ Control Node ]   |   |    [ Storage Node ]   |   |    [ Compute Node ]   |
|                       |   |                       |   |                       |
|  MariaDB    RabbitMQ  |   |      Open vSwitch     |   |        Libvirt        |
|  Memcached  httpd     |   |     Neutron Server    |   |     Nova Compute      |
|  Keystone   Glance    |   |       OVN-Northd      |   |      Open vSwitch     |
|  Nova API             |   |     Cinder Volume     |   |   OVN Metadata Agent  |
|  Cinder API           |   |     iSCSI Target      |   |     OVN-Controller    |
|                       |   |    Heat API/Engine    |   |                       |
+-----------------------+   +-----------------------+   +-----------------------+

[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 |
+--------------------------------------+------------+--------+
| ba8781c7-85ef-4872-957e-2c27b55275b2 | Ubuntu2004 | active |
+--------------------------------------+------------+--------+

root@dlp ~(keystone)#
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 35816d4c-fa30-4901-8aa5-3749970fa706 | public  | 694a93ec-762f-4c2e-b8f3-4f5aa72b631e |
| a5d44a8a-4980-4c19-a53a-26af6aabd732 | private | 77ab8a8b-9cca-4f4a-90c6-a61f8a58f08d |
+--------------------------------------+---------+--------------------------------------+

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=Ubuntu2004;NetID=$Int_Net_ID" Sample-Stack

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 1a4e6d2c-8238-452d-9d8d-2ae8ed15e075 |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2021-10-08T00:03:01Z                 |
| 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 |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 1a4e6d2c-8238-452d-9d8d-2ae8ed15e075 | Sample-Stack | f4431102f2d9415590e3ac11c616858a | CREATE_COMPLETE | 2021-10-08T00:03:01Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

root@dlp ~(keystone)#
openstack server list

+--------------------------------------+----------------------+--------+-------------------------+------------+----------+
| ID                                   | Name                 | Status | Networks                | Image      | Flavor   |
+--------------------------------------+----------------------+--------+-------------------------+------------+----------+
| bbebb224-925b-4f43-a318-1322cf6cd3c7 | Heat_Deployed_Server | ACTIVE | private=192.168.100.106 | Ubuntu2004 | 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 を利用したい場合は、設定変更が必要です。
root@dlp ~(keystone)#
openstack role list

+----------------------------------+------------------+
| ID                               | Name             |
+----------------------------------+------------------+
| 2d9c6c4a1fbe4fd6aecbbc1aa6f939e8 | member           |
| 4ea4942f45f4490bb2885cc5a28526bf | heat_stack_user  |
| 633cd44ec02246dfb51b402274a7ae25 | heat_stack_owner |
| 95387bd895fc4e57b9f68cafe1e8376a | admin            |
| c06a64c6001e42df8f03b157d1b1fe1a | reader           |
| d09ce5f970e447cbb88558c4a91b0cef | CloudUser        |
+----------------------------------+------------------+

root@dlp ~(keystone)#
openstack project list

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 611e3ba8938b475fb9dd8124603f18d3 | service   |
| f4431102f2d9415590e3ac11c616858a | admin     |
| facc545a7f9e4218884c40169158a2dc | hiroshima |
+----------------------------------+-----------+

root@dlp ~(keystone)#
openstack user list

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| cf04da25a4b04d5983a1bfaeaa5830f7 | admin             |
| 67b144163ad54b4fb3bad7c731fe0330 | glance            |
| 77db0f264e8647808f3823c2f20d5801 | nova              |
| 73565cb500354a309fa8174450ead2cd | placement         |
| 944be1c8d2cc49458dc29875c17ad7fc | neutron           |
| f5a7ffdd6e54434badbd75ba0e6d6ac2 | serverworld       |
| 8ea432b3a36a4fc9a90d96ad6c524413 | cinder            |
| 5589e11f41304de4abecf9ec264b12f2 | heat              |
| cbb9e7b95a47486fa3129e5fae4d531b | heat_domain_admin |
+----------------------------------+-------------------+

# 例として [hiroshima] プロジェクトの [serverworld] ユーザーを [heat_stack_owner] ロールに追加

root@dlp ~(keystone)#
openstack role add --project hiroshima --user serverworld heat_stack_owner
# Neutron Server 稼働ノードで Neutron の設定を変更

root@network:~#
vi /etc/neutron/policy.json
# 以下の内容で新規作成

# 管理者のみに許可されている権限を設定なしで上書きする

{
  "create_port:fixed_ips:subnet_id": "",
  "create_port:allowed_address_pairs": "",
  "create_port:allowed_address_pairs:ip_address": "",
}

root@network:~#
systemctl restart neutron-server

# 以上で一般ユーザーでも以下のようにスタックが作成できる

ubuntu@dlp ~(keystone)$
openstack stack list

+--------------------------------------+--------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name   | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 95529dee-21aa-46b2-bd72-57c3dbebc7e6 | Sample-Stack | CREATE_COMPLETE | 2021-10-08T00:07:03Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+
| ID                                   | Name                 | Status  | Networks                            | Image      | Flavor   |
+--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+
| a399eba9-aca1-4f0f-855b-abfe3eded2bb | Heat_Deployed_Server | ACTIVE  | private=192.168.100.31              | Ubuntu2004 | m1.small |
| 4699d575-1d94-4024-8323-9dfa3599c8d2 | Ubuntu-2004          | SHUTOFF | private=10.0.0.249, 192.168.100.237 | Ubuntu2004 | m1.small |
+--------------------------------------+----------------------+---------+-------------------------------------+------------+----------+
関連コンテンツ