Ubuntu 16.04
Sponsored Link

OpenStack Ocata : How to use Heat2017/03/18

 
How to use the OpenStack Orchestration Service (Heat).
This example is based on the emvironment like follows.
     ------------+--------------------------------+--------------------------------+------------
                 |                                |                                |
             eth0|10.0.0.30                   eth0|10.0.0.50                   eth0|10.0.0.51
     +-----------+-----------+        +-----------+-----------+        +-----------+-----------+
     |    [ Control Node ]   |        |    [ Network Node ]   |        |    [ Compute Node ]   |
     |                       |        |                       |        |                       |
     |  MariaDB    RabbitMQ  |        |      Open vSwitch     |        |        Libvirt        |
     |  Memcached  httpd     |        |  L2,L3,Metadata Agent |        |      Nova Compute     |
     |  Keystone   Glance    |        |  Heat API   API-CFN   |        |        L2 Agent       |
     |  Nova API             |        |  Heat Engine          |        |                       |
     |  Neutron Server       |        |                       |        |                       |
     +-----------------------+        +-----------------------+        +-----------------------+

[1] Deploy Instances with Heat services and templates. The example below is on the Controle Node.
# create a template for test

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

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 |
+--------------------------------------+--------------+--------+
| 94b334bf-178f-46b2-ac6f-4e49de6442a1 | Ubuntu1604   | active |
+--------------------------------------+--------------+--------+

root@dlp ~(keystone)#
openstack network list

+---------------------------------+---------+----------------------------------+
| ID                              | Name    | Subnets                          |
+---------------------------------+---------+----------------------------------+
| 6897f95e-eb43-4041-a22a-        | int_net | 2cff7f3d-6e5c-49be-              |
| 6b2f417d3bc5                    |         | ba88-e930c8090864                |
| add5e0b3-f838-41ec-a14c-        | ext_net | 161a0667-f2ae-4962-b969-2c391729 |
| 184f0442d6b3                    |         | 004f                             |
+---------------------------------+---------+----------------------------------+

root@dlp ~(keystone)#
Int_Net_ID=`openstack network list | grep int_net | awk '{ print $2 }'`
# create an instance from the template

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 61b932ac-4865-486f-9d3f-7270e912a0cf |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2017-03-20T01:50:59Z                 |
| updated_time        | None                                 |
| stack_status        | CREATE_IN_PROGRESS                   |
| stack_status_reason | Stack CREATE started                 |
+---------------------+--------------------------------------+

# turn to "CREATE_COMPLETE" after few minutes later like follows

root@dlp ~(keystone)#
openstack stack list

+---------------+--------------+---------------+----------------+--------------+
| ID            | Stack Name   | Stack Status  | Creation Time  | Updated Time |
+---------------+--------------+---------------+----------------+--------------+
| 61b932ac-4865 | Sample-Stack | CREATE_COMPLE | 2017-03-20T01: | None         |
| -486f-9d3f-   |              | TE            | 50:59Z         |              |
| 7270e912a0cf  |              |               |                |              |
+---------------+--------------+---------------+----------------+--------------+

# the instance is running which is created from the Heat template

root@dlp ~(keystone)#
openstack server list

+-----------------+-----------------+---------+-------------------+------------+
| ID              | Name            | Status  | Networks          | Image Name |
+-----------------+-----------------+---------+-------------------+------------+
| e68f5fd4-958e-4 | Heat_Deployed_S | ACTIVE  | int_net=192.168.1 | Ubuntu1604 |
| 348-8b25-bbad6a | erver           |         | 00.4              |            |
| 30a077          |                 |         |                   |            |
| 9b506f0f-4c3b-4 | Ubuntu_1604     | SHUTOFF | int_net=192.168.1 | Ubuntu1604 |
| 58b-9213-17de1c |                 |         | 00.6, 10.0.0.203  |            |
| 4da03c          |                 |         |                   |            |
+-----------------+-----------------+---------+-------------------+------------+

# delete the instance likwe follows if you don't need

root@dlp ~(keystone)#
openstack stack delete --yes 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)#
openstack stack list

+----+------------+--------------+---------------+
| id | stack_name | stack_status | creation_time |
+----+------------+--------------+---------------+
+----+------------+--------------+---------------+
[2]
The guide for writing templates are opened on the official site below.
⇒ http://docs.openstack.org/developer/heat/template_guide/index.html
Matched Content