Ubuntu 16.04
Sponsored Link

OpenStack Mitaka (三鷹) : Heat 利用方法2016/06/08

 
OpenStack Orchestration Service(Heat)の利用方法です。
ここでは以下のような環境を例に設定しています。
                                |
+------------------+            |            +------------------------+
| [ Control Node ] |            |            |    [ Network Node ]    |
|     Keystone     |10.0.0.30   |   10.0.0.50|    DHCP,L3,L2 Agent    |
|      Glance      |------------+------------|     Metadata Agent     |
|     Nova API     |eth0        |        eth0|    Heat API,API-CFN    |
|  Neutron Server  |            |            |       Heat Engine      |
+------------------+            |            +------------------------+
                            eth0|10.0.0.51
                      +--------------------+
                      |  [ Compute Node ]  |
                      |    Nova Compute    |
                      |      L2 Agent      |
                      +--------------------+

[1] 構築した Heat サービスとテンプレートを利用してインスタンスをデプロイします。 作業は、どこでもよいですが、ここではコントロールノード上で行います。
# テスト用テンプレート作成

root@dlp ~(keystone)#
vi sample-stack.yml
heat_template_version: 2016-04-08

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)#
glance image-list

+--------------------------------------+------------+
| ID                                   | Name       |
+--------------------------------------+------------+
| d7e743c4-c1f5-458b-abc5-2d9176c07a93 | Ubuntu1604 |
+--------------------------------------+------------+

root@dlp ~(keystone)#
neutron net-list

+--------------------------------------+---------+-------------------------------------------------------+
| id                                   | name    | subnets                                               |
+--------------------------------------+---------+-------------------------------------------------------+
| 770a1018-973c-43bc-8922-26238b7bcde5 | ext_net | 24bee302-ab35-43fc-b415-3930d1e01902 10.0.0.0/24      |
| 4b658dd5-bc91-40d4-8268-c1fa2cfdfff0 | int_net | 3c232880-5aca-42fd-b9f9-a077cf5e6a39 192.168.100.0/24 |
+--------------------------------------+---------+-------------------------------------------------------+

root@dlp ~(keystone)#
Int_Net_ID=`neutron net-list | grep int_net | awk '{ print $2 }'`
# サンプルテンプレートからインスタンス作成

root@dlp ~(keystone)#
heat stack-create -f sample-stack.yml -P "ImageID=Ubuntu1604;NetID=$Int_Net_ID" Sample-Stack

+--------------------------------------+--------------+--------------------+---------------------+--------------+
| id                                   | stack_name   | stack_status       | creation_time       | updated_time |
+--------------------------------------+--------------+--------------------+---------------------+--------------+
| 5040ab16-54cb-468b-ae4a-0b474a4930ac | Sample-Stack | CREATE_IN_PROGRESS | 2016-06-09T11:28:33 | None         |
+--------------------------------------+--------------+--------------------+---------------------+--------------+

# しばらく待つとステータスがコンプリートになる

root@dlp ~(keystone)#
heat stack-list

+--------------------------------------+--------------+-----------------+---------------------+--------------+
| id                                   | stack_name   | stack_status    | creation_time       | updated_time |
+--------------------------------------+--------------+-----------------+---------------------+--------------+
| 5040ab16-54cb-468b-ae4a-0b474a4930ac | Sample-Stack | CREATE_COMPLETE | 2016-06-09T11:28:33 | None         |
+--------------------------------------+--------------+-----------------+---------------------+--------------+

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

root@dlp ~(keystone)#
nova list

+--------------------------------------+----------------------+---------+------------+-------------+-----------------------------------+
| ID                                   | Name                 | Status  | Task State | Power State | Networks                          |
+--------------------------------------+----------------------+---------+------------+-------------+-----------------------------------+
| c6ea1f23-d031-4f35-9360-d5163b3bc225 | Heat_Deployed_Server | ACTIVE  | -          | Running     | int_net=192.168.100.4             |
| 545457b2-517f-4a3b-bae2-bb99beb8342a | Ubuntu_1604          | SHUTOFF | -          | Shutdown    | int_net=192.168.100.3, 10.0.0.201 |
+--------------------------------------+----------------------+---------+------------+-------------+-----------------------------------+

# 作成したものを削除する

root@dlp ~(keystone)#
heat stack-delete Sample-Stack

Are you sure you want to delete this stack(s) [y/N]?
y

+--------------------------------------+--------------+-----------------+---------------------+--------------+
| id                                   | stack_name   | stack_status    | creation_time       | updated_time |
+--------------------------------------+--------------+-----------------+---------------------+--------------+
| 5040ab16-54cb-468b-ae4a-0b474a4930ac | Sample-Stack | CREATE_COMPLETE | 2016-06-09T11:28:33 | None         |
+--------------------------------------+--------------+-----------------+---------------------+--------------+

root@dlp ~(keystone)#
heat stack-list

+----+------------+--------------+---------------+
| id | stack_name | stack_status | creation_time |
+----+------------+--------------+---------------+
+----+------------+--------------+---------------+
[2]
テンプレートの記述方法のガイドは公式サイトに記載されているので参考にしてください。
⇒ http://docs.openstack.org/developer/heat/template_guide/index.html
関連コンテンツ