OpenStack Ocata : How to use Heat2017/03/05 |
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 | | Open vSwitch | | Nova API | | Heat Engine | | L2 Agent | | Neutron Server | | | | | +-----------------------+ +-----------------------+ +-----------------------+ |
[1] | Deploy Instances with Heat services and templates. The example below is on the Controle Node. |
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 | +--------------------------------------+---------+--------+ | c13b45a8-5664-4169-93c7-625ae2e561e9 | CentOS7 | active | +--------------------------------------+---------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 0caa61ce-db39-44dc-9c54-a50bb48fae08 | ext_net | a3cc573a-8066-49a1-bf0e-21ed53595452 | | e82354f3-7820-421f-b8d6-0b67ff26f5c2 | int_net | 4a0d9278-6b06-4809-9b35-e7facff737d2 | +--------------------------------------+---------+--------------------------------------+[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=CentOS7;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | 2a274806-0756-4e18-9b87-20ae93175345 | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2017-03-05T09:48:09Z | | 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 | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 2a274806-0756-4e18-9b87-20ae93175345 | Sample-Stack | CREATE_COMPLETE | 2017-03-05T09:48:09Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template [root@dlp ~(keystone)]# openstack server list +-----------+----------------------+---------+-----------------------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------------------+---------+-----------------------------------+------------+ | 6c97e6c5- | Heat_Deployed_Server | ACTIVE | int_net=192.168.100.6 | CentOS7 | | b17e0565- | CentOS_7 | SHUTOFF | int_net=192.168.100.5, 10.0.0.201 | CentOS7 | +-----------+----------------------+---------+-----------------------------------+------------+ # delete the instance likwe follows if you don't need [root@dlp ~(keystone)]# openstack stack delete --yes Sample-Stack
[root@dlp ~(keystone)]#
[root@dlp ~(keystone)]# openstack stack list openstack server list +-----------+----------------------+---------+-----------------------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------------------+---------+-----------------------------------+------------+ | b17e0565- | CentOS_7 | SHUTOFF | int_net=192.168.100.5, 10.0.0.201 | CentOS7 | +-----------+----------------------+---------+-----------------------------------+------------+ |
[2] |
The guide for writing templates are opened on the official site below.
⇒ http://docs.openstack.org/developer/heat/template_guide/index.html |
Sponsored Link |