CentOS Stream 8
Sponsored Link

OpenStack Yoga : Heat 利用方法2022/06/01

 
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 サービスとテンプレートを利用してインスタンスをデプロイします。
作業場所は、どこでもよいですが、当例ではコントロールノード上で行います。
# Heat クライアントを Yoga, EPEL, PowerTools を有効にしてインストール

[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-yoga,powertools,epel -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 |
+--------------------------------------+-----------------+--------+
| 7be5b7ab-36e8-43c7-95dd-34b4139a0e44 | CentOS-Stream-8 | active |
+--------------------------------------+-----------------+--------+

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

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 0c96d581-95f3-4e72-9626-d0a94407d0ec | public  | e20328ce-a24a-4804-be39-88f18800526f |
| 0f0af4c7-f2d1-4c13-b30c-4619ff33db0c | private | 748c0a25-c6d8-48fd-829e-8b15783b7f8a |
+--------------------------------------+---------+--------------------------------------+

[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                  | 2f5a9033-cf2f-41e6-844a-3fd56a132d90 |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2022-06-01T05:08:54Z                 |
| 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 |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 2f5a9033-cf2f-41e6-844a-3fd56a132d90 | Sample-Stack | 0609d3b3b398456187fb705ec9224c4a | CREATE_COMPLETE | 2022-06-01T05:08:54Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

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

+--------------------------------------+----------------------+--------+------------------------+-----------------+----------+
| ID                                   | Name                 | Status | Networks               | Image           | Flavor   |
+--------------------------------------+----------------------+--------+------------------------+-----------------+----------+
| 20182739-d2d9-4084-85c6-237b43f3cb42 | Heat_Deployed_Server | ACTIVE | private=192.168.100.84 | 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             |
+----------------------------------+------------------+
| 092c3c3e1ca74f12957c01bbbdbacf35 | CloudUser        |
| 1bc22cc802be4976b955668b2da25052 | heat_stack_owner |
| 4c9e739222cb47daafb8e8184e380ae4 | admin            |
| 6765ea4d8ea64eae8c5f24dd0d9fa4d4 | member           |
| 6d521d08fa1b4abcbe709ee858e80cb7 | heat_stack_user  |
| 99938d7dbeb747f3a803c81d7b0d83e0 | reader           |
+----------------------------------+------------------+

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

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 0609d3b3b398456187fb705ec9224c4a | admin     |
| 3d85d1e79d654b3dade01eb5bfbf0679 | hiroshima |
| 8787527217494c6a87dd5a3b68dce1ef | service   |
+----------------------------------+-----------+

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

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| 63596ba65a1b45d5890f6407152692c7 | admin             |
| 2aafe40cdb944b618294bcc2310cfdf9 | glance            |
| 4e1fe87e017d476283845f55e12ae058 | nova              |
| 3ac1fb9042e24d2a92e524f4f16bc154 | placement         |
| beb862be39184dd89a3faa71b930181e | neutron           |
| ed0bc393ae81411fa1db0828e1d5e160 | serverworld       |
| 8f0b83f989df495a82deea1ca315acb5 | cinder            |
| b612f4de926740cd887f5335bc114fbf | heat              |
| bbe9ed86fec848428e978fea21c40278 | 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 |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 9272cdaa-141d-47e2-a1fa-193524cdaea7 | Sample-Stack | CREATE_COMPLETE | 2022-06-01T05:16:07Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+

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

+--------------------------------------+----------------------+---------+-------------------------------------+-----------------+----------+
| ID                                   | Name                 | Status  | Networks                            | Image           | Flavor   |
+--------------------------------------+----------------------+---------+-------------------------------------+-----------------+----------+
| d1f022ea-fa60-4ac8-aba4-b1ba1c726920 | Heat_Deployed_Server | ACTIVE  | private=192.168.100.207             | CentOS-Stream-8 | m1.small |
| fa3a20c0-f0f4-46eb-b63f-69abba312d03 | CentOS-St8           | SHUTOFF | private=10.0.0.251, 192.168.100.140 | CentOS-Stream-8 | m1.small |
+--------------------------------------+----------------------+---------+-------------------------------------+-----------------+----------+
関連コンテンツ