This lesson will introduce you to a very important topic of OpenStack Heat, a software provisioning tool on an OpenStack platform.
Tip
Duration: 1 hour
OpenStack Heat is an open source software to deploy services within OpenStack clouds. Heat launches VM instances, installs cloud software and manages required resources such as security groups or floating ip addresses within a resource group, a stack. You just need to describe your cloud services and resources in a Heat Template file, and OpenStack deploys your cloud services by provisioning cloud infrastructure and installing/configuring software. Through this lesson, you will learn how to write a Heat Template file and how to deploy your cloud applications with a command line tool or a web interface. OpenStack Heat Orchestration Template (HOT) is compatible with AWS CloudFormation template format, there are some extensions of Heat Templates though. If you have AWS templates, you can use them on OpenStack as well to start your cloud services.
This lesson covers:
Let’s start with the basics of OpenStack Heat.
Heat creates a stack with a combination of resources. The following resource types are the most common items to start or connect each other, we may see often how they are deployed and interact.
There are 70 resource types in total. See more at: http://docs.openstack.org/hot-reference/content/openstack-resource-types.html
These are OpenStack Heat Resource types which are identified with the OS::
prefix.
For example, if you’d like to start a VM instance, use the OS::Nova::Server
resource type.
There are also Amazon CloudFormation compatible resource types.
These resource types are exchangeable between Amazon (AWS) and OpenStack. Let’s review a few types.
AWS::EC2::Instance
: EC2 Instance <-> Nova ServerAWS::EC2::SecurityGroup
: EC2 Security Group <-> OpenStack Security GroupAWS::EC2::Volume
: AWS Elastic Block Store volume <-> OpenStack Cinder
VolumeCurrently, 25 resource types are compatible with AWS, AWS supports 88 resource types on Amazon Cloud though.
For more information,
OpenStack Heat templates are written in a YAML file format which is easy to read and write. The following template is an example of a launching a VM server with Ubuntu 14.04 image and 1 vCPU and 2GB memories (m1.small flavor).
heat_template_version: 2013-05-23
description: Simple template to deploy a single compute instance on FutureSystems
resources:
my_instance:
type: OS::Nova::Server
properties:
key_name: albert-india-key
image: futuresystems/ubuntu-14.04
flavor: m1.small
Heat template starts with a heat_template_version
key to indicate supported
features and resource types. The following values are supported:
We start learning OpenStack Heat on india.futuresystems.org. You can use Heat on FutureSystems via a web interface Horizon or a command line tool (Heat CLI). On a Horizon dashboard, graphical resource topology is displayed and relations of connected resources are also presented in a canvas. If you use command line tools, various command options (which might not be visible on a the web) and debugging messages are available.
The Horizon on FutureSystems is at: https://openstack-j.india.futuresystems.org/horizon/project/
For more details of Horizon: OpenStack Web Dashboard (Horizon)
If you’d like to use Heat Client Tool (heat CLI), you simply run the following commands on india.futuresystems.org:
module load openstack
source $HOME/.cloudmesh/clouds/india/juno/openrc.sh
Note
If you run OpenStack Havana, try the following commands:
module load openstack-havana; module load heatclient; source $HOME/.cloudmesh/clouds/india/havana/novarc;
module load openstack
enables Heat CLI on your shell.
You can see running stacks with the following command:
$ heat stack-list
+----+------------+--------------+---------------+
| id | stack_name | stack_status | creation_time |
+----+------------+--------------+---------------+
+----+------------+--------------+---------------+
A stack
is cloud resources that you use with your selected Heat Template. If
you deployed 5 VM instances with 2 floating IP addresses and 1 security group,
all of these resources fall into a single stack on OpenStack.
You need a template first. Save a sample template above in a YAML file, e.g.
openstack_heat_ex1.yaml
It will create a new VM instance with a Ubuntu
14.04
image, albert-india-key
SSH keypair and a m1.small
flavor. You
have to REPLACE albert-india-key
with your registered keyname.
If you are ready to create a new stack, run the following command:
heat stack-create --template-file openstack_heat_ex1.yaml heat-tutorial-$OS_USERNAME
--template-file
.heat-tutorial-$OS_USERNAME
is your stack name, you can use other names.Note
If you have a template file on the web, you can use a URL with
--template-url
parameter.
The sample output is:
+--------------------------------------+------------+--------------------+----------------------+
| id | stack_name | stack_status | creation_time |
+--------------------------------------+------------+--------------------+----------------------+
| a6c98d15-f569-426b-a364-46bcca831049 | heat-tut...| CREATE_IN_PROGRESS | 2015-04-02T06:15:56Z |
+--------------------------------------+------------+--------------------+----------------------+
As you can see your stack is being processed. You can see more details with the following command:
heat stack-show heat-tutorial-$OS_USERNAME
The output looks like:
+----------------------+----------------------------------------------------------------------------+
| Property | Value |
+----------------------+----------------------------------------------------------------------------+
| capabilities | [] |
| creation_time | 2015-04-02T06:15:56Z |
| description | Simple template to deploy a single compute instance on FutureSystems |
| disable_rollback | True |
| id | a6c98d15-f569-426b-a364-46bcca83104 |
| links | http://xxx.futuregrid.org:xxx/v1/.../stacks/../.. (self) |
| notification_topics | [] |
| parameters | { |
| | "OS::stack_id": "a6c98d15-f569-426b-a364-46bcca83104", |
| | "OS::stack_name": "heat-tutorial-albert", |
| | "instance_type": "m1.small", |
| | "image_id": "futuresystems/ubuntu-14.04", |
| | "key_name": "albert-india-key" |
| | } |
| parent | None |
| stack_name | heat-tutorial-albert |
| stack_owner | albert |
| stack_status | CREATE_COMPLETE |
| stack_status_reason | Stack CREATE completed successfully |
| template_description | Simple template to deploy a single compute instance on FutureSystems |
| updated_time | None |
+----------------------+----------------------------------------------------------------------------+
heat stack-list [STACK_NAME]
If you have VM instances in your stack, you can see running instances.
nova list
heat stack-delete [STACK_NAME]
You can find examples of the Heat templates.
https://github.com/openstack/heat-templates/blob/master/hot/
Try to create a two VM instances with the following conditions:
$USERNAME_heat_ex1.yaml
Tip
The following documents will be useful:
Start a WordPress web service using Heat template on the web. The required conditions are:
key_name
parametercurl -L http://[IP ADDRESS]/wordpress
produces the index page in a text mode.Tip
Examine the documentation for the heat
subcommands
stack-create
and stack-show
like so:
$ heat help <subcommand>
replacing <subcommand>
as appropriate.
Tip
The IP address of your instance is listed as an output value. Make sure to examine your stack to get the location of the instance.
Submission
You will need to turn in a typescript of your terminal session. Do so by executing:
$ script heat_ex2_$OS_USERNAME.typescript
and then proceed with this exercise. Upon completion, make sure to
type exit
to end the typescripting. The contents of the session
will be found in the heat_ex2_$OS_USERNAME.typescript
file.
If you’d like to use Horizon web dashboard, you need to find “Orchestration > Stacks” menu.
Stacks > Topology
Stacks > Overview
Stacks > Resources
Stacks > Events
If you’d like to learn more about OpenStack Heat? Please follow the links below:
More glossary are: http://docs.openstack.org/developer/heat/glossary.html