CentOS Stream 9
Sponsored Link

OpenStack Bobcat : Heat 利用方法2023/10/25

 
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  Nginx     |  |     Neutron Server    |  |      Nova Compute     |
|  Keystone   httpd     |  |      OVN-Northd       |  |      Open vSwitch     |
|  Glance     Nova API  |  |  Nginx  iSCSI Target  |  |   OVN Metadata Agent  |
|  Cinder API           |  |     Cinder Volume     |  |     OVN-Controller    |
|                       |  |    Heat API/Engine    |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

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

[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-bobcat,epel,crb -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 |
+--------------------------------------+----------------+--------+
| bcbaa323-2438-4f5e-9473-49f633bb8f9b | CentOS-Stream9 | active |
+--------------------------------------+----------------+--------+

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

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 1245127b-0e5c-49c1-8638-de9d51c34949 | private | 88416326-c3b5-4e6f-bf53-71a77c213721 |
| 44e70c99-2e15-429b-9dcc-cccaac557c0c | public  | fac5715e-35f6-4007-9e8f-edffb2629eeb |
+--------------------------------------+---------+--------------------------------------+

[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                  | 77785ddd-6bdd-4118-87d5-46b7278d2ebd |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2023-10-25T04:19:12Z                 |
| 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 |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 77785ddd-6bdd-4118-87d5-46b7278d2ebd | Sample-Stack | d9d13fdc603c42f69a0ea034b64a3cdb | CREATE_COMPLETE | 2023-10-25T04:19:12Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

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

+--------------------------------------+----------------------+--------+------------------------+----------------+----------+
| ID                                   | Name                 | Status | Networks               | Image          | Flavor   |
+--------------------------------------+----------------------+--------+------------------------+----------------+----------+
| 1df448f8-ca58-4e8f-b7da-e0f39ae70bc5 | Heat_Deployed_Server | ACTIVE | private=192.168.100.36 | CentOS-Stream9 | 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 を利用したい場合は、Heat 用のロールに追加すれば OK です。
[root@dlp ~(keystone)]#
openstack role list

+----------------------------------+------------------+
| ID                               | Name             |
+----------------------------------+------------------+
| 47337a4ce8bc428a8b39bb8e32ad6a22 | reader           |
| 6a0da2e6047d4fabb752ef05e628c19d | manager          |
| 6ae93bec02354a19a18d0cae975034fe | member           |
| b4b84af37fc34fc78efa5ab4b8595abe | service          |
| b4ba3b0aa39e4789b3e5ac1100dbbcda | heat_stack_user  |
| cacd2a524a2b47e1b8c4e4d6906ed2fd | admin            |
| f24c7e0ee421455895f15f726cd7ca77 | heat_stack_owner |
+----------------------------------+------------------+

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

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 5d97881520b34e6bbf1f15e778c82fe4 | service   |
| d9d13fdc603c42f69a0ea034b64a3cdb | admin     |
| f4598dfd3b8a47149234b6892d18d5a4 | hiroshima |
+----------------------------------+-----------+

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

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| f551447b6e4a4593ba4172942385b4d8 | admin             |
| c5b1b17555cb4865b57936019cc63b1f | glance            |
| 44499d297d7e4449bbdb63ef6c6013dd | nova              |
| a4786e29c5f14ccc94a50adc133249bb | placement         |
| 6800bf9762fd4a5b823dbedf60ec6181 | neutron           |
| d70a5f7908de4cd9aa8e189b725244a9 | serverworld       |
| 41a29789f66e4f5787acba22bd4c5490 | cinder            |
| 77a3c465363a4026857fb7e3895c51d4 | heat              |
| febc43063411454fb9c2c4e77f82b220 | heat_domain_admin |
+----------------------------------+-------------------+

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

[root@dlp ~(keystone)]#
openstack role add --project hiroshima --user serverworld heat_stack_owner
# 以上で一般ユーザーでも以下のようにスタックが作成できる

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

+--------------------------------------+--------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name   | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 7451c26c-1517-4343-b274-1fd883b29a68 | Sample-Stack | CREATE_COMPLETE | 2023-10-25T04:23:22Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+

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

+--------------------------------------+----------------------+---------+------------------------------------+----------------+-----------+
| ID                                   | Name                 | Status  | Networks                           | Image          | Flavor    |
+--------------------------------------+----------------------+---------+------------------------------------+----------------+-----------+
| b655b78b-935f-4891-b72b-5287ab7daebf | Heat_Deployed_Server | ACTIVE  | private=192.168.100.60             | CentOS-Stream9 | m1.small  |
| 78b8c394-be14-4312-84e8-06eeebbd74f3 | CentOS-St9           | SHUTOFF | private=10.0.0.208, 192.168.100.63 | CentOS-Stream9 | m1.medium |
+--------------------------------------+----------------------+---------+------------------------------------+----------------+-----------+
関連コンテンツ