OpenStack - オーケストレーション (Heat) サービスの導入とインストール

OpenStack - オーケストレーション (Heat) サービスの導入とインストール

OpenStack Heat は、インフラストラクチャ リソースの自動展開と管理のためのテンプレートベースのオーケストレーション サービスです。これにより、ユーザーはテンプレート ファイルを作成して必要なインフラストラクチャ リソースと構成を記述し、Heat エンジンを使用してこれらのテンプレートを解析して実行し、クラウド環境でリソースを自動的に作成、構成、管理できます。

たとえば、Web サーバーとしての仮想マシン、データを保存するためのストレージ ボリューム、および仮想マシンとストレージ ボリュームを接続するためのネットワークを必要とする Web アプリケーションがあるとします。Heat テンプレートを使用して、これらのリソースとリソース間の関係を記述することができます。テンプレートでは、仮想マシンのイメージ、ネットワークのサブネット、ストレージ ボリュームのサイズなどの属性を指定し、リソース間の依存関係を定義できます。たとえば、ストレージ ボリュームが作成されるまで仮想マシンは起動できません。創造された。このテンプレートを作成したら、Heat サービスを使用してアプリケーションをデプロイおよび管理できます。Heat は、テンプレートの記述に基づいて、仮想マシン、ストレージ ボリューム、ネットワークなどのリソースを自動的に作成および構成します。これらのリソースを更新または削除する必要がある場合は、テンプレートを変更して Heat コマンドを再実行するだけで、テンプレートの変更に従って対応するリソースが自動的に更新または削除されます。

インストールと設定 (コントローラー)

準備する

公式ドキュメント

Heat サービス コンポーネントを構成する前に、データベース、サービス証明書、および API エンドポイントを作成する必要があります。

(1)データベースの作成

①オペレーティングシステム端末でデータベースに接続します。

[root@controller ~]# mysql -uroot -p000000

heatデータベースの作成

MariaDB [(none)]> CREATE DATABASE heat;

③熱データベース访问权限设置

MariaDB [(none)]> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'%'  IDENTIFIED BY '000000';

④データベースを終了する

(2) 管理者ユーザーの環境変数を読み込みます

[root@controller ~]# source admin-openrc.sh

(3)サービス認証情報の作成

①Heatユーザーを作成する

[root@controller ~]# openstack user create --domain default --password 000000 heat
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | c2774323d7e04a529d1fcdc18d6549f9 |
| name                | heat                             |
| options             | {
    
    }                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

②アドミン为用户添加角色ヒート

[root@controller ~]# openstack role add --project service --user heat admin

③熱・熱CFNサービス事業体の構築

[root@controller ~]# openstack service create --name heat  --description "Orchestration" orchestration
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Orchestration                    |
| enabled     | True                             |
| id          | 7ce739d29f3841ad9bed4d286f546bd7 |
| name        | heat                             |
| type        | orchestration                    |
+-------------+----------------------------------+
[root@controller ~]# openstack service create --name heat-cfn --description "Orchestration"  cloudformation
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Orchestration                    |
| enabled     | True                             |
| id          | f1c9a2b146b94d75b19a13f1b806e4d8 |
| name        | heat-cfn                         |
| type        | cloudformation                   |
+-------------+----------------------------------+

(4) Heat オーケストレーション サービス コンポーネントの API エンドポイントを作成する

[root@controller ~]# openstack endpoint create --region RegionOne  orchestration public http://controller:8004/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field        | Value                                   |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id           | 56d9afe212be479394529d2e5b33e9bc        |
| interface    | public                                  |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 7ce739d29f3841ad9bed4d286f546bd7        |
| service_name | heat                                    |
| service_type | orchestration                           |
| url          | http://controller:8004/v1/%(tenant_id)s |
+--------------+-----------------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne  orchestration internal http://controller:8004/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field        | Value                                   |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id           | b77211d055ac468094a1834318a24341        |
| interface    | internal                                |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 7ce739d29f3841ad9bed4d286f546bd7        |
| service_name | heat                                    |
| service_type | orchestration                           |
| url          | http://controller:8004/v1/%(tenant_id)s |
+--------------+-----------------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne orchestration admin http://controller:8004/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field        | Value                                   |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id           | 02f7ab4296a94dc1ac909cf7e83b91bc        |
| interface    | admin                                   |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | 7ce739d29f3841ad9bed4d286f546bd7        |
| service_name | heat                                    |
| service_type | orchestration                           |
| url          | http://controller:8004/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
 [root@controller ~]# openstack endpoint create --region RegionOne cloudformation public http://controller:8000/v1
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 26264981dd3a414aa18fd64e4ec2ba84 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | f1c9a2b146b94d75b19a13f1b806e4d8 |
| service_name | heat-cfn                         |
| service_type | cloudformation                   |
| url          | http://controller:8000/v1        |
+--------------+----------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne cloudformation internal http://controller:8000/v1
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 9b4f604bb0984b63ad050655762a7d41 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | f1c9a2b146b94d75b19a13f1b806e4d8 |
| service_name | heat-cfn                         |
| service_type | cloudformation                   |
| url          | http://controller:8000/v1        |
+--------------+----------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne cloudformation admin http://controller:8000/v1
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 9c8c76a1b03a44a8a7728fa47670410e |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | f1c9a2b146b94d75b19a13f1b806e4d8 |
| service_name | heat-cfn                         |
| service_type | cloudformation                   |
| url          | http://controller:8000/v1        |
+--------------+----------------------------------+

(5) オーケストレーション サービスを作成するには、スタックを操作するための情報を Identity サービスに追加する必要があります

①ヒートドメインの作成

[root@controller ~]# openstack domain create --description "Stack projects and users" heat
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Stack projects and users         |
| enabled     | True                             |
| id          | 3fb118462aa344ba8c0fb36fc0296fa7 |
| name        | heat                             |
| options     | {
    
    }                               |
| tags        | []                               |
+-------------+----------------------------------+

②Heatドメイン内のプロジェクトとユーザーを管理するためのheat_domain_adminユーザーを作成します

[root@controller ~]# openstack user create --domain heat --password-prompt heat_domain_admin
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | 3fb118462aa344ba8c0fb36fc0296fa7 |
| enabled             | True                             |
| id                  | 2632b29ed7a746e4bf01466c475fcf57 |
| name                | heat_domain_admin                |
| options             | {
    
    }                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

ドメイン内のユーザーadminにロールを追加し、ユーザーの管理スタック管理権限を有効にします。heat_domain_adminheatheat_domain_admin

[root@controller ~]# openstack role add --domain heat --user-domain heat --user heat_domain_admin admin

④heat_stack_ownerロールを作成する

[root@controller ~]# openstack role create heat_stack_owner
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | None                             |
| domain_id   | None                             |
| id          | 816798fab0bf4825a4a71d36ade47f44 |
| name        | heat_stack_owner                 |
| options     | {
    
    }                               |
+-------------+----------------------------------+

デモユーザーがスタックを管理できるようにプロジェクトとユーザーheat_stack_ownerにロールを追加しますdemo

[root@controller ~]# openstack role add --project demo --user demo heat_stack_owner

⑥heat_stack_user_roleの作成

[root@controller ~]# openstack role create heat_stack_user
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | None                             |
| domain_id   | None                             |
| id          | a1b8a79460f04f28ba5c12bc372304d3 |
| name        | heat_stack_user                  |
| options     | {
    
    }                               |
+-------------+----------------------------------+

Heat オーケストレーション サービス コンポーネントのインストールと構成

(1)ソフトウェアパッケージのインストール

[root@controller ~]# yum install -y openstack-heat-api openstack-heat-api-cfn openstack-heat-engine openstack-heat-ui

(2)設定ファイル

/etc/heat/heat.confファイルを編集し、次の操作を完了します。

[database]セクションではデータベースアクセスの設定を行います

[database]
connection = mysql+pymysql://heat:000000@controller/heat

[DEFAULT]セクションでRabbitMQメッセージキューへのアクセスを設定します

[DEFAULT]
transport_url = rabbit://openstack:000000@controller

③ 、[keystone_authtoken][trustee]セクション[clients_keystone]で、アイデンティティ サービス アクセスを構成します。

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = heat
password = 000000

[trustee]
auth_type = password
auth_url = http://controller:5000
username = heat
password = 000000
user_domain_name = default

[clients_keystone]
auth_uri = http://controller:5000

[DEFAULT]セクションでは、メタデータと待機条件のURLを設定します

[DEFAULT]
heat_metadata_server_url = http://controller:8000
heat_waitcondition_server_url = http://controller:8000/v1/waitcondition

[DEFAULT]セクションで、スタックドメインと管理資格情報を設定します。

[DEFAULT]
stack_domain_admin = heat_domain_admin
stack_domain_admin_password = 000000
stack_user_domain_name = heat

(3) データベースの同期

[root@controller ~]#  su -s /bin/sh -c "heat-manage db_sync" heat

インストールを完了する

オーケストレーション サービスを開始し、起動時に自動的に開始するように構成します。

[root@controller ~]# systemctl start openstack-heat-api.service  openstack-heat-api-cfn.service openstack-heat-engine.service &&  systemctl enable openstack-heat-api.service  openstack-heat-api-cfn.service openstack-heat-engine.service
# 自行查看log文件是否报错

確認する

(1) 環境変数の読み込み

[root@controller ~]# source admin-openrc.sh

(2) Heat オーケストレーション サービス コンポーネントのプロセスが正常に開始および登録されているかどうかを一覧表示します。

[root@controller ~]# openstack orchestration service list
+------------+-------------+--------------------------------------+------------+--------+----------------------------+--------+
| Hostname   | Binary      | Engine ID                            | Host       | Topic  | Updated At                 | Status |
+------------+-------------+--------------------------------------+------------+--------+----------------------------+--------+
| controller | heat-engine | 4c0919cf-a36b-449c-8fa6-4dad9f355a43 | controller | engine | 2023-07-01T01:53:55.000000 | up     |
| controller | heat-engine | acc70835-f179-44c7-9ae6-e900cdda1fa8 | controller | engine | 2023-07-01T01:53:55.000000 | up     |
| controller | heat-engine | f9dc47f6-06ad-4dbb-afc5-7f4138b58d3b | controller | engine | 2023-07-01T01:53:55.000000 | up     |
| controller | heat-engine | 7c95fd77-74f8-4cd9-ac8e-984c36554ad8 | controller | engine | 2023-07-01T01:53:55.000000 | up     |
+------------+-------------+--------------------------------------+------------+--------+----------------------------+--------+

Heat テンプレートを作成し、yaml ファイルを実行して heat-swift という名前のコンテナーを作成します。

[root@controller ~]# vim swift.yaml 
heat_template_version: 2014-10-16
description: "创建容器"
resources:
  user:
    type: OS::Swift::Container
    properties:
      name: heat-swift
[root@controller ~]# openstack stack create csqstack -t create_container.yaml 
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 82f6fda4-fa1c-4cc7-b8f1-340f6e13d266 |
| stack_name          | csqstack                             |
| description         | 创建容器                             |
| creation_time       | 2023-07-01T11:49:09Z                 |
| updated_time        | None                                 |
| stack_status        | CREATE_IN_PROGRESS                   |
| stack_status_reason | Stack CREATE started                 |
+---------------------+--------------------------------------+
[root@controller ~]# swift list
heat-swift

Guess you like

Origin blog.csdn.net/qq_52089863/article/details/131487982