Ubuntu 16.04
Sponsored Link

OpenStack Pike : Heat 利用方法2017/09/18

 
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  |   |        L2 Agent       |   |        Libvirt        |
     |  Memcached  httpd     |   |        L3 Agent       |   |     Nova Compute      |
     |  Keystone   Glance    |   |     Metadata Agent    |   |        L2 Agent       |
     |  Nova API             |   |     Cinder-Volume     |   |                       |
     |  Neutron Server       |   |       Heat API        |   |                       |
     |  Metadata Agent       |   |      Heat Engine      |   |                       |
     |  Cinder API           |   |                       |   |                       |
     +-----------------------+   +-----------------------+   +-----------------------+

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

root@dlp ~(keystone)#
vi sample-stack.yml
heat_template_version: 2017-09-01

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 |
+--------------------------------------+------------+--------+
| 1f46b995-47e3-4858-b0b0-9221867462cc | Ubuntu1604 | active |
+--------------------------------------+------------+--------+

root@dlp ~(keystone)#
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 5adc2598-4ebe-4110-b6bf-47d9e2b5c48e | ext_net | 6572863d-f10a-456e-932c-2581d39a3349 |
| fcfcf86c-40a6-4c79-9431-feb74dc5a6bc | int_net | 65e69dd1-0b8c-43d7-9c44-b8099a2e0f82 |
+--------------------------------------+---------+--------------------------------------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | f704dddd-7f9e-498f-a4fc-99997f350faa |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2017-09-20T04:09:59Z                 |
| 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 |
+-----------+--------------+----------------+-----------------+----------------------+--------------+
| f704dddd- | Sample-Stack | 1ca37b956ae... | CREATE_COMPLETE | 2017-09-20T04:09:59Z | None         |
+-----------+--------------+----------------+-----------------+----------------------+--------------+

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

root@dlp ~(keystone)#
openstack server list

+-----------+----------------------+---------+------------------------------------+------------+----------+
| ID        | Name                 | Status  | Networks                           | Image      | Flavor   |
+-----------+----------------------+---------+------------------------------------+------------+----------+
| 99c7a965- | Heat_Deployed_Server | ACTIVE  | int_net=192.168.100.6              | Ubuntu1604 | m1.small |
| f5ae3046- | Ubuntu_1604          | SHUTOFF | int_net=192.168.100.10, 10.0.0.210 | Ubuntu1604 | m1.small |
+-----------+----------------------+---------+------------------------------------+------------+----------+

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

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

root@dlp ~(keystone)#
openstack stack list

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