OpenStack Icehouse : How to use Heat2015/02/02 |
How to use the OpenStack Orchestration Service (Heat).
This example is based on the environment like follows.
| +------------------+ | +------------------------+ | [ 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] | Deploy Instances with Heat services and templates. The example below is on the Controle Node. |
heat_template_version: 2013-05-23 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 | Disk Format | Container Format | Size | Status | +--------------------------------------+---------+-------------+------------------+------------+--------+ | 8862e58a-ccb9-4251-a70e-03524cedf83c | CentOS6 | qcow2 | bare | 1104478208 | active | +--------------------------------------+---------+-------------+------------------+------------+--------+[root@dlp ~(keystone)]# Int_Net_ID=`neutron net-list | grep int_net | awk '{ print $2 }'`
# create an instance from the template [root@dlp ~(keystone)]# heat stack-create -f sample-stack.yml -P "ImageID=CentOS6;NetID=$Int_Net_ID" Sample-Stack +--------------------------------------+--------------+--------------------+----------------------+ | id | stack_name | stack_status | creation_time | +--------------------------------------+--------------+--------------------+----------------------+ | 29875283-f0b7-46ea-a860-8ea889b9135b | Sample-Stack | CREATE_IN_PROGRESS | 2015-02-03T14:05:52Z | +--------------------------------------+--------------+--------------------+----------------------+ # turn to "CREATE_COMPLETE" after few minutes later like follows [root@dlp ~(keystone)]# heat stack-list +--------------------------------------+--------------+-----------------+----------------------+ | id | stack_name | stack_status | creation_time | +--------------------------------------+--------------+-----------------+----------------------+ | 29875283-f0b7-46ea-a860-8ea889b9135b | Sample-Stack | CREATE_COMPLETE | 2015-02-03T14:05:52Z | +--------------------------------------+--------------+-----------------+----------------------+ # the instance is running which is created from the Heat template [root@dlp ~(keystone)]# nova list +----------------+----------------------+--------+------------+-------------+-----------------------+ | ID | Name | Status | Task State | Power State | Networks | +----------------+----------------------+--------+------------+-------------+-----------------------+ | 88c571ed-d5d3- | Heat_Deployed_Server | ACTIVE | - | Running | int_net=192.168.100.4 | +----------------+----------------------+--------+------------+-------------+-----------------------+ # delete the instance likwe follows if you don't need [root@dlp ~(keystone)]# heat stack-delete Sample-Stack +--------------------------------------+--------------+--------------------+----------------------+ | id | stack_name | stack_status | creation_time | +--------------------------------------+--------------+--------------------+----------------------+ | 29875283-f0b7-46ea-a860-8ea889b9135b | Sample-Stack | DELETE_IN_PROGRESS | 2015-02-03T14:05:52Z | +--------------------------------------+--------------+--------------------+----------------------+[root@dlp ~(keystone)]# heat 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 Furthermore, some templates are provided like follows. |
# install templates [root@network ~]# yum --enablerepo=openstack-icehouse,epel -y install openstack-heat-templates # there are templates under the directory below [root@network ~]# ll /usr/share/openstack-heat-templates total 20 drwxr-xr-x 6 root root 4096 Feb 4 20:07 cfn drwxr-xr-x 5 root root 4096 Feb 4 20:07 hot drwxr-xr-x 2 root root 4096 Feb 4 20:07 jeos drwxr-xr-x 4 root root 4096 Feb 4 20:07 openshift-enterprise drwxr-xr-x 4 root root 4096 Feb 4 20:07 openshift-origin |
Sponsored Link |
|