CentOS Stream 8
Sponsored Link

OpenStack Victoria : Heat 利用方法
2021/03/24
 
OpenStack Orchestration Service(Heat)の利用方法です。
当例では以下のような環境を例に Orchestration サービスを設定しています。
------------+---------------------------+---------------------------+------------
            |                           |                           |
        eth0|10.0.0.30              eth0|10.0.0.50              eth0|10.0.0.51
+-----------+-----------+   +-----------+-----------+   +-----------+-----------+
|    [ 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 Volume     |   |   OVN Metadata Agent  |
|  Cinder API           |   |      iSCSI Target     |   |     OVN-Controller    |
|                       |   |     Heat API/Engine   |   |                       |
+-----------------------+   +-----------------------+   +-----------------------+

[1] 構築した Heat サービスとテンプレートを利用してインスタンスをデプロイします。
作業場所は、どこでもよいですが、当例ではコントロールノード上で行います。
# Heat クライアントを Victoria, EPEL, PowerTools を有効にしてインストール

[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-victoria,powertools,epel -y install python3-heatclient
# テスト用テンプレート作成

[root@dlp ~(keystone)]#
vi sample-stack.yml
heat_template_version: 2018-08-31

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 |
+--------------------------------------+-----------------+--------+
| 4d7293af-be5b-471b-9507-2a32f1955b11 | CentOS-Stream-8 | active |
+--------------------------------------+-----------------+--------+

[root@dlp ~(keystone)]#
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 9f53c3b1-ec6b-499d-854a-588d3b0b96d6 | private | 94afb0cc-1d58-4615-8fef-8852271bfc16 |
| ea9725cf-a8bc-4eb5-a374-7d7d0e11453c | public  | 63c29d7b-e870-477d-819b-e5dfe41af1d0 |
+--------------------------------------+---------+--------------------------------------+

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 784508fe-4b71-4a80-9cc4-b88e97eb453e |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2021-03-24T08:03:23Z                 |
| 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 |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 784508fe-4b71-4a80-9cc4-b88e97eb453e | Sample-Stack | b9bf51c6436a4c5aa7a2df05688afb49 | CREATE_COMPLETE | 2021-03-24T08:03:23Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------------------+--------+------------------------+-----------------+----------+
| ID                                   | Name                 | Status | Networks               | Image           | Flavor   |
+--------------------------------------+----------------------+--------+------------------------+-----------------+----------+
| 105acdb0-1f84-42e2-b5e4-45c184aae40d | Heat_Deployed_Server | ACTIVE | private=192.168.100.61 | CentOS-Stream-8 | m1.small |
+--------------------------------------+----------------------+--------+------------------------+-----------------+----------+

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

[root@dlp ~(keystone)]#
openstack stack delete --yes Sample-Stack

[root@dlp ~(keystone)]#
openstack stack list
[root@dlp ~(keystone)]#
openstack server list


[2]
テンプレートの記述方法のガイドは公式サイトに記載されているので参考にしてください。
⇒ https://docs.openstack.org/heat/latest/template_guide/index.html
[3] 一般ユーザーでも Heat を利用したい場合は、設定変更が必要です。
[root@dlp ~(keystone)]#
openstack role list

+----------------------------------+------------------+
| ID                               | Name             |
+----------------------------------+------------------+
| 4c700d9cf8e74d15939866751160b8e2 | CloudUser        |
| 50c665f9fef44e94859f3917fa5209d7 | reader           |
| 57f0601d9b9f4836b6f606c64e58b083 | heat_stack_owner |
| bd7c20ef06864388806511e3c1f6f3a9 | heat_stack_user  |
| c8e2eb5f05d54f0292628e9304648c15 | member           |
| f7e97312fb04428bae7ff4506dde29dc | admin            |
+----------------------------------+------------------+

[root@dlp ~(keystone)]#
openstack project list

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| affa3a6446154e37adfd233c437bacc1 | service   |
| b9bf51c6436a4c5aa7a2df05688afb49 | admin     |
| f1f04d774d2141fb9acabd28d0e00c33 | hiroshima |
+----------------------------------+-----------+

[root@dlp ~(keystone)]#
openstack user list

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| 431cac9bf8244de39edbbf9bf69ef84c | admin             |
| 95da4d31df43419ebb1e495e5eb180bd | glance            |
| ddc826fcee8f4695a6af91e71add144f | nova              |
| d32e7f6fce6f4f639d72c8a8eabc7dd4 | placement         |
| fdf65d0b49ee4bd6a2713219139d5af9 | neutron           |
| e08c35de3b6746bd9518c97f7068a71e | serverworld       |
| 37eac0fbdeb346a0b37e8e48d977f4ae | cinder            |
| a43acdb98b314569b8a837784dda00a2 | heat              |
| c19fd0eabc8947478bd3539f2357cde1 | 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

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

[cent@dlp ~(keystone)]$
openstack stack list

+--------------------------------------+--------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name   | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 6be4b981-816a-4c9e-987b-9327c6d97d52 | Sample-Stack | CREATE_COMPLETE | 2021-03-24T08:13:00Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------------------+---------+------------------------------------+-----------------+----------+
| ID                                   | Name                 | Status  | Networks                           | Image           | Flavor   |
+--------------------------------------+----------------------+---------+------------------------------------+-----------------+----------+
| 1b1cac4e-0796-4f35-a448-4b5a87ed94e1 | Heat_Deployed_Server | ACTIVE  | private=192.168.100.37             | CentOS-Stream-8 | m1.small |
+--------------------------------------+----------------------+---------+------------------------------------+-----------------+----------+
関連コンテンツ