Support: 1-800-961-4454
1-800-961-2888

Say ‘Hello Heat!’ With Havana-Powered Rackspace Private Cloud

EDITOR’S NOTE: OpenStack Orchestration (Heat) is currently available as a technology preview feature  and is unsupported with the Rackspace Private Cloud.

In a previous blog, I showed how easy it was to install OpenStack Grizzly on the Rackspace open cloud. More recently, I blogged about project Solum. Solum is based on project Heat, which was recently introduced in Havana. Heat is available as a technology preview with the latest release of the Rackspace Private Cloud.

Here, I will talk a little more about Heat and we will say Hello to Heat with a simple “Hello Heat” exercise.

My “Hello Heat” exercise was defined as follows.

  • To install the Havana-based Rackspace Private Cloud and install the technology preview of Heat based on Chef recipes
  • To try out some basic Heat CLI commands, such as stack-create, stack-list and stack-delete
  • To orchestrate stacks using Horizon
  • To log in to the instance(s) that were created

The goal of this exercise was to be able to install Heat and do a very simple introductory tour. The Heat Orchestrated Template (HOT for short) can be used to install complex application stacks. I have chosen a stack that launches Cirros instance(s) for this exercise. All you need is an account on the Rackspace open cloud!

Overview of Heat

Heat is an OpenStack project introduced in Havana. It is based on AWS CloudFormation, the goal of which is to provision infrastructure deployments repeatedly and automatically. For example, you can create a deployment with a load balancer, multiple web servers and database(s). These application deployments are referred to as stacks and are created using templates based on Heat Orchestrated Templates (HOT). Obviously, the complexity of the HOT file will depend on the complexity of the application stack. These stacks can be carefully orchestrated and launched in multiple availability zones as required.

Overview of Steps

The steps involved in the process are as follows.

  1. Install Havana-based Rackspace Private Cloud with Heat
  2. Create a keypair that will be used to launch the stack and to ssh to the instance created
  3. Create a simple HOT template to launch a stack
  4. Explore some Heat commands in the CLI
  5. Explore how to use Heat in Horizon
  6. If everything goes well, use the application stacks that were just created

Step 1 – Install latest Havana Release of Rackspace Private Cloud with Heat

You can create an Ubuntu instance on mycloud.rackspace.com by providing the appropriate credentials (you need an account). You can follow the steps outlined in my previous blog, but with the following changes.

Pick “Ubuntu 12.04 LTS (Precise Pangolin)” for Image and a flavor of 4GB or higher.

Use the following modified syntax of the environment file for the 4.2.x (Havana-based) releases.

{
  "name": "rpcs",
  "description": "Environment for Rackspace Private Cloud (Havana)", 
  "cookbook_versions": {
  },
  "json_class": "Chef::Environment",
  "chef_type": "environment",
  "default_attributes": {
  },
  "override_attributes": {
    "nova": {
      "libvirt": {
        "virt_type": "qemu"
      },
      "networks": {
        "public" : {
          "label": "public",
          "bridge_dev": "eth1",
          "dns1": "8.8.8.8",
          "dns2": "8.8.4.4",
          "num_networks": "1",
          "ipv4_cidr": "10.0.100.0/24",
          "network_size": "255",
          "bridge": "br100"
        }
      }
    },
    "mysql": {
      "allow_remote_root": true,
      "root_network_acl": "%"
    },
    "osops_networks": {
      "nova": "162.209.105.0/24",
      "public": "162.209.105.0/24",
      "management": "162.209.105.0/24"
    }
  }
}

Install the Heat role in addition to the Controller role and Compute role using the roles heat-all and allinone

knife bootstrap petcattle -E rpcs -r 'role[allinone], role[heat-all]'

Verify that Heat is installed by running the heat stack-list command. There are no stacks running (yet).

heat stack-list

Step 2 – Create a Keypair

Create a key pair on petcattle using the ssh-keygen command, accepting the defaults for the command.

ssh-keygen

This command will create the key pairs in the directory ~/.ssh.

Import the public key ~/.ssh/id_rsa.pub.

more ~/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDcdbbzUxL+iQuLYQ+lZ615S9ogirx68dBr/OHIHfHJuyX38CKydFhFEbegZD7NcDj2A4XWV0uJgDbup25rC7edGiDXyY
7/l3IeSM2v/FbQmQGICc5V8DstpbacTfwWAOTJIBwIJgYWfprQwockmrcD2sPenDlxL3iWpNm5K9fnnAXc6ULfeNd7SM4KV2cCN2m7NwheVwpjOO888Y2o9rRq92Jm6b3x
dFAHNkw2fX0/kx6Xh82Mu5M0VrVrhu++YDir2xp5Oq3kvzXOr/1kJMksbRYds+asFuyrh0yegaHvQdEVVdLAVsJ+tQ56bsZXrWdY0SI7lTu2pdB7SiGAJi8F root@petcattle

Import via Horizon using the “Access and Security” tab, “Keypairs” tab and “Import Keypair” button with the name admin as outlined below.

Step 3 – Create a simple HOT template and launch a stack

Create a simple HOT template file called HelloHeat.yaml with the following contents. This is based on the HelloWord template file on github. It is expressed in YAML (which also includes JSON, a subset of YAML).

We modified this just a little bit to be able to orchestrate the creation of two instances. Although this HOT template file is self-explanatory, the HOT specification documentation goes into much greater detail of the power beyond Heat.

# This is a hello world HOT template just defining a single compute instance
heat_template_version: 2013-05-23

description: >
  Hello world HOT template that just defines a single compute instance.
  Contains just base features to verify base HOT support.

parameters:
  KeyName:
    type: string
    description: Name of an existing key pair to use for the instance
  InstanceType:
    type: string
    description: Instance type for the instance to be created
    default: m1.small
    constraints:
      - allowed_values: [m1.tiny, m1.small, m1.large]
        description: Value must be one of 'm1.tiny', 'm1.small' or 'm1.large'
  ImageId:
    type: string
    description: ID of the image to use for the instance
  # parameters below are not used in template, but are for verifying parameter
  # validation support in HOT
  db_password:
    type: string
    description: Database password
    hidden: true
    constraints:
      - length: { min: 6, max: 8 }
        description: Password length must be between 6 and 8 characters
      - allowed_pattern: "[a-zA-Z0-9]+"
        description: Password must consist of characters and numbers only
      - allowed_pattern: "[A-Z]+[a-zA-Z0-9]*"
        description: Password must start with an uppercase character
  db_port:
    type: number
    description: Database port number
    default: 50000
    constraints:
      - range: { min: 40000, max: 60000 }
        description: Port number must be between 40000 and 60000

resources:
  my_instance1:
    # Use an AWS resource type since this exists; so why use other name here?
    type: AWS::EC2::Instance
    properties:
      KeyName: { get_param: KeyName }
      ImageId: { get_param: ImageId }
      InstanceType: { get_param: InstanceType }

  my_instance2:
    # Use an AWS resource type since this exists; so why use other name here?
    type: AWS::EC2::Instance
    properties:
      KeyName: { get_param: KeyName }
      ImageId: { get_param: ImageId }
      InstanceType: { get_param: InstanceType }

outputs:
  instance_ip1:
    description: The IP address of the deployed instance
    value: { get_attr: [my_instance1, PublicIp] }
  instance_ip2:
    description: The IP address of the deployed instance
    value: { get_attr: [my_instance2, PublicIp] }

Step 4 – Launch a stack via the CLI

Note down the image ID of the cirros image that we will use to launch the stack using the following command:

glance image-list

+--------------------------------------+--------+-------------+------------------+-----------+--------+
| ID                                   | Name   | Disk Format | Container Format | Size      | Status |
+--------------------------------------+--------+-------------+------------------+-----------+--------+
| 9889e157-6e7e-4e56-99b0-e79c5466fdd4 | Cirros | qcow2       | bare             | 13147648  | active |
+--------------------------------------+--------+-------------+------------------+-----------+--------+

In the example above, the image ID is 9889e157-6e7e-4e56-99b0-e79c5466fdd4.

Verify that there are no compute instances running with the following command

nova list

Launch the stack as below providing the appropriate image ID, the key name and a permitted instance type.

heat stack-create --template-file=HelloHeat.yaml  --parameters="db_password=PassW1;KeyName=admin;InstanceType=m1.tiny;ImageId=9889e157-6e7e-4e56-99b0-e79c5466fdd4" Stack101
+--------------------------------------+------------+--------------------+----------------------+
| id                                   | stack_name | stack_status       | creation_time        |
+--------------------------------------+------------+--------------------+----------------------+
| 51944d65-f2b9-41e7-85e3-1f08cddd0e7b | Stack101   | CREATE_IN_PROGRESS | 2014-01-13T20:45:03Z |
+--------------------------------------+------------+--------------------+----------------------+

Although, we will not use the parameter db_password, it could be used in the HOT template file to customize the application stack deployment.

Verify the status of the stack creation as below:

heat stack-show Stack101
+----------------------+---------------------------------------------------------------------------------------------------------------------------------+
| Property             | Value                                                                                                                           |
+----------------------+---------------------------------------------------------------------------------------------------------------------------------+
| capabilities         | []                                                                                                                              |
| creation_time        | 2014-01-13T20:45:03Z                                                                                                            |
| description          | Hello world HOT template that just defines a single                                                                             |
|                      | compute instance. Contains just base features to verify                                                                         |
|                      | base HOT support.                                                                                                               |
| disable_rollback     | True                                                                                                                            |
| id                   | 51944d65-f2b9-41e7-85e3-1f08cddd0e7b                                                                                            |
| links                | http://162.209.105.100:8004/v1/992b93a1d8f2420aa5e423630a4b61eb/stacks/Stack101/51944d65-f2b9-41e7-85e3-1f08cddd0e7b            |
| notification_topics  | []                                                                                                                              |
| outputs              | [                                                                                                                               |
|                      |   {                                                                                                                             |
|                      |     "output_value": "10.0.100.2",                                                                                               |
|                      |     "description": "The IP address of the deployed instance",                                                                   |
|                      |     "output_key": "instance_ip1"                                                                                                |
|                      |   },                                                                                                                            |
|                      |   {                                                                                                                             |
|                      |     "output_value": "10.0.100.4",                                                                                               |
|                      |     "description": "The IP address of the deployed instance",                                                                   |
|                      |     "output_key": "instance_ip2"                                                                                                |
|                      |   }                                                                                                                             |
|                      | ]                                                                                                                               |
| parameters           | {                                                                                                                               |
|                      |   "db_password": "******",                                                                                                      |
|                      |   "AWS::StackName": "Stack101",                                                                                                 |
|                      |   "ImageId": "9889e157-6e7e-4e56-99b0-e79c5466fdd4",                                                                            |
|                      |   "AWS::StackId": "arn:openstack:heat::992b93a1d8f2420aa5e423630a4b61eb:stacks/Stack101/51944d65-f2b9-41e7-85e3-1f08cddd0e7b",  |
|                      |   "KeyName": "admin",                                                                                                           |
|                      |   "db_port": "50000",                                                                                                           |
|                      |   "AWS::Region": "ap-southeast-1",                                                                                              |
|                      |   "InstanceType": "m1.tiny"                                                                                                     |
|                      | }                                                                                                                               |
| stack_name           | Stack101                                                                                                                        |
| stack_status         | CREATE_COMPLETE                                                                                                                 |
| stack_status_reason  | Stack create completed successfully                                                                                             |
| template_description | Hello world HOT template that just defines a single                                                                             |
|                      | compute instance. Contains just base features to verify                                                                         |
|                      | base HOT support.                                                                                                               |
| timeout_mins         | 60                                                                                                                              |
| updated_time         | 2014-01-13T20:45:19Z                                                                                                            |
+----------------------+---------------------------------------------------------------------------------------------------------------------------------+

This shows a successful stack creation with two instances that have an IP address of 10.0.100.2 and 10.0.100.4.

Using the following command, you can verify that the instances created as a result of launching the stack are running:

nova list
+--------------------------------------+------------------------------------+--------+------------+-------------+-------------------+
| ID                                   | Name                               | Status | Task State | Power State | Networks          |
+--------------------------------------+------------------------------------+--------+------------+-------------+-------------------+
| 01c28497-34ef-4403-b5a9-d29650ea5f5a | Stack101-my_instance1-i6qwutnvvt3u | ACTIVE | None       | Running     | public=10.0.100.2 |
| c6dd55e5-b3f8-4bb0-8c1d-1f83da8af18f | Stack101-my_instance2-y4npyn5vptxc | ACTIVE | None       | Running     | public=10.0.100.4 |
+--------------------------------------+------------------------------------+--------+------------+-------------+-------------------+

Step 5 – Launch a stack using Horizon

Use the Stacks tab under Orchestration and hit the “+ Launch Stack” button.

Provide the following values for “Direct Input” and the contents of the template file in “Template Data” then hit the “Next” button.

Provide the respective parameters as outlined below and hit “Launch.”

Eventually the stack creation will be complete as below.

Step 6 – Use the instance of the Application Stack that was just created.

ssh -i ~/.ssh/id_rsa cirros@10.0.100.2
The authenticity of host '10.0.100.2 (10.0.100.2)' can't be established.
RSA key fingerprint is fc:8b:96:cb:ad:91:cd:36:0f:a8:87:89:0f:a6:99:8d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.100.2' (RSA) to the list of known hosts.
$

ssh -i ~/.ssh/id_rsa cirros@10.0.100.4
The authenticity of host '10.0.100.4 (10.0.100.4)' can't be established.
RSA key fingerprint is 63:aa:e6:ee:7c:77:69:c1:26:2d:1d:9b:81:8d:a3:c7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.100.4' (RSA) to the list of known hosts.
$

Congratulations! You just completed the “Hello Heat!” exercise!

Summary and follow up

The goal of this exercise was to get Heat up and running very quickly.  There are a number of HOT templates aimed at deploying more advanced stacks than the one we created. You can scour the Rackspace Knowledge Center and read up on the article on Heat to gain a better understanding and to help you further with these efforts.

About the Author

This is a post written and contributed by Raghavan "Rags" Srinivas.

Raghavan "Rags" Srinivas works as a solutions architect at Rackspace where he finds himself constantly challenged from low level networking to high level application issues. His general focus area is in distributed systems, with a specialization in Cloud Computing and Big Data. He worked on Hadoop, HBase and NoSQL during its early stages. He has spoken on a variety of technical topics at conferences around the world, conducted and organized Hands-on Labs and taught graduate classes in the evening.

Rags brings with him over 20 years of hands-on software development and over 10 years of architecture and technology evangelism experience. He has evangelized and influenced the architecture of a number of technology areas. He is also a repeat JavaOne rock star speaker award winner.

Rags holds a Masters degree in Computer Science from the Center of Advanced Computer Studies at the University of Louisiana at Lafayette. He likes to hike, run and generally be outdoors, but most of all he loves to eat.


More
Racker Powered
©2014 Rackspace, US Inc.