OpenStack Juno : How to use Heat2015/01/27 |
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: 2014-10-16 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 | +--------------------------------------+---------+-------------+------------------+-----------+--------+ | 4a663fce-97eb-42d3-93d6-415e477bc0a4 | CentOS7 | qcow2 | bare | 974454784 | 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=CentOS7;NetID=$Int_Net_ID" Sample-Stack +--------------------------------------+--------------+--------------------+----------------------+ | id | stack_name | stack_status | creation_time | +--------------------------------------+--------------+--------------------+----------------------+ | 1410dd42-1317-4dc9-b106-f038d077848b | Sample-Stack | CREATE_IN_PROGRESS | 2015-01-28T13:42:37Z | +--------------------------------------+--------------+--------------------+----------------------+ # turn to "CREATE_COMPLETE" after few minutes later like follows [root@dlp ~(keystone)]# heat stack-list +--------------------------------------+--------------+-----------------+----------------------+ | id | stack_name | stack_status | creation_time | +--------------------------------------+--------------+-----------------+----------------------+ | 1410dd42-1317-4dc9-b106-f038d077848b | Sample-Stack | CREATE_COMPLETE | 2015-01-28T13:42:37Z | +--------------------------------------+--------------+-----------------+----------------------+ # the instance is running which is created from the Heat template [root@dlp ~(keystone)]# nova list +-----------+----------------------+--------+------------+-------------+-----------------------+ | ID | Name | Status | Task State | Power State | Networks | +-----------+----------------------+--------+------------+-------------+-----------------------+ | 60d1dfd1- | Heat_Deployed_Server | ACTIVE | - | Running | int_net=192.168.100.7 | +-----------+----------------------+--------+------------+-------------+-----------------------+ # 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 | +--------------------------------------+--------------+--------------------+----------------------+ | 1410dd42-1317-4dc9-b106-f038d077848b | Sample-Stack | DELETE_IN_PROGRESS | 2015-01-28T13:42:37Z | +--------------------------------------+--------------+--------------------+----------------------+[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-juno,epel -y install openstack-tripleo-heat-templates # there are templates under the directory below [root@network ~]# ll /usr/share/openstack-tripleo-heat-templates total 232 -rw-r--r-- 1 root root 1968 Oct 10 04:06 base.yaml -rw-r--r-- 1 root root 2325 Oct 10 04:06 block-storage-nfs.yaml -rw-r--r-- 1 root root 1841 Oct 10 04:06 block-storage.yaml -rw-r--r-- 1 root root 5989 Oct 21 23:17 cinder-storage.yaml -rw-r--r-- 1 root root 14073 Oct 21 23:17 compute.yaml -rw-r--r-- 1 root root 25581 Oct 21 23:17 controller.yaml -rw-r--r-- 1 root root 1004 Oct 10 04:06 debian-mirror.yaml -rw-r--r-- 1 root root 4262 Oct 10 04:06 nagios3.yaml -rw-r--r-- 1 root root 632 Oct 10 04:06 nfs-server-source.yaml -rw-r--r-- 1 root root 3046 Oct 10 04:06 nova-compute-config.yaml -rw-r--r-- 1 root root 9370 Oct 10 04:06 nova-compute-instance.yaml -rw-r--r-- 1 root root 197 Oct 21 23:17 overcloud-resource-registry.yaml -rw-r--r-- 1 root root 30819 Oct 10 04:06 overcloud-source.yaml -rw-r--r-- 1 root root 1384 Oct 10 04:06 overcloud-vlan-port.yaml -rw-r--r-- 1 root root 26292 Oct 21 23:17 overcloud-without-mergepy.yaml -rw-r--r-- 1 root root 2145 Oct 10 04:06 ssl-source.yaml -rw-r--r-- 1 root root 2153 Oct 10 04:06 swift-deploy.yaml -rw-r--r-- 1 root root 518 Oct 10 04:06 swift-source.yaml -rw-r--r-- 1 root root 2482 Oct 10 04:06 swift-storage-source.yaml -rw-r--r-- 1 root root 5100 Oct 21 23:17 swift-storage.yaml -rw-r--r-- 1 root root 881 Oct 10 04:06 undercloud-bm-nova-config.yaml -rw-r--r-- 1 root root 1303 Oct 10 04:06 undercloud-bm-nova-deploy.yaml -rw-r--r-- 1 root root 12560 Oct 10 04:06 undercloud-source.yaml -rw-r--r-- 1 root root 1351 Oct 10 04:06 undercloud-vlan-port.yaml -rw-r--r-- 1 root root 978 Oct 10 04:06 undercloud-vm-ironic-config.yaml -rw-r--r-- 1 root root 1575 Oct 10 04:06 undercloud-vm-ironic-deploy.yaml -rw-r--r-- 1 root root 1063 Oct 10 04:06 undercloud-vm-nova-config.yaml -rw-r--r-- 1 root root 1847 Oct 10 04:06 undercloud-vm-nova-deploy.yaml |
Sponsored Link |