OpenStack Pike : How to use Heat2017/09/07 |
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 Agent | | Nova Compute | | Keystone Glance | | L3 Agent | | Open vSwitch | | Nova API | | Metadata Agent | | L2 Agent | | Neutron Server | | Cinder-Volume | | | | Metadata Agent | | Heat API API-CFN | | | | Cinder API | | Heat Engine | | | +-----------------------+ +-----------------------+ +-----------------------+ |
[1] | Deploy Instances with Heat services and templates. The example below is on the Controle Node. |
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 | +--------------------------------------+---------+--------+ | 68132026-60aa-4afe-8976-398b0482cfd6 | CentOS7 | active | +--------------------------------------+---------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | b70e8cdc-8c61-4a3b-8dfc-060cba8f82f9 | int_net | 3627d5d7-8196-469f-897e-2159f695052a | | e27d7f02-773f-4e11-8aa9-e70ebc05ab76 | ext_net | 85f3a6a0-07ab-493d-91a3-cd60ecd908c7 | +--------------------------------------+---------+--------------------------------------+[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 | f9130fe1-e40b-4c90-baaf-66a6f48ec1bc | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2017-09-08T08:14:12Z | | 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 | Project | Stack Status | Creation Time | Updated Time | +-----------+--------------+---------------+-----------------+----------------------+--------------+ | f9130fe1- | Sample-Stack | 09158bee8c... | CREATE_COMPLETE | 2017-09-08T08:14:12Z | None | +-----------+--------------+---------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template [root@dlp ~(keystone)]# openstack server list +-----------+----------------------+---------+------------------------------------+---------+----------+ | ID | Name | Status | Networks | Image | Flavor | +-----------+----------------------+---------+------------------------------------+---------+----------+ | bf95857b- | Heat_Deployed_Server | ACTIVE | int_net=192.168.100.11 | CentOS7 | m1.small | | 662f62b8- | CentOS_7 | SHUTOFF | int_net=192.168.100.12, 10.0.0.201 | CentOS7 | m1.small | +-----------+----------------------+---------+------------------------------------+---------+----------+ # 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 | Flavor | +-----------+----------+---------+------------------------------------+---------+----------+ | 662f62b8- | CentOS_7 | SHUTOFF | int_net=192.168.100.12, 10.0.0.201 | CentOS7 | m1.small | +-----------+----------+---------+------------------------------------+---------+----------+ |
[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 |