Openstack Orchestration - Heat
- Get link
- X
- Other Apps
After having struggled through with various building blocks of OpenStack, Heat was a great relief. It's installation and integration was pretty smooth.
One of the most helpful documents was this one.
By definition
"The Orchestration service provides a template-based orchestration for describing a cloud application by running OpenStack API calls to generate running cloud applications."
The templates enable you to create most OpenStack resource types, such as instances, floating IPs, volumes, security groups, users, and so on. Also, provides some more advanced functionality, such as instance high availability, instance auto-scaling, and nested stacks. By providing very tight integration with other OpenStack core projects, all OpenStack core projects could receive a larger user base.
Components of the Orchestration service
heat
command-line client. A CLI that communicates with the heat-api to run AWS CloudFormation APIs. End developers could also use the Orchestration REST API directly.heat-api
component. Provides an OpenStack-native REST API that processes API requests by sending them to the heat-engine over RPC.heat-api-cfn
component. Provides an AWS Query API that is compatible with AWS CloudFormation and processes API requests by sending them to the heat-engine over RPC.heat-engine
. Orchestrates the launching of templates and provides events back to the API consumer.
Installation
Installing in the controller node
- yum install openstack-heat-api openstack-heat-engine openstack-heat-api- cfn
Edit the heat.conf file in /etc/heat/ directory. And the
sql_connection=mysql://heat:heat@controller/heat
Going into the database to create the heat database and give it the privileges.
- $ mysql -u root -p
- mysql> CREATE DATABASE heat;
- mysql> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'localhost' \
- IDENTIFIED BY 'HEAT_DBPASS';
- mysql> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'%' \
- IDENTIFIED BY 'HEAT_DBPASS';
The tables in the database get created using the below command
- heat-manage db_sync
there are some DeprecationWarning errors, which can be ignored.
Pool.__init__(self, creator, **kw)
/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py:159: SADeprecationWarning: Pool.add_listener is deprecated. Use event.listen()
self.add_listener(l)
creating the heat user and registering the service
- keystone user-create --name=heat --pass=HEAT_PASS --email=heat@example.com
- $ keystone user-role-add --user=heat --tenant=service --role=admin
And edit the heat.conf file to change the [keystone_authtoken] and [ec2_authtoken] section
[keystone_authtoken]auth_host = controllerauth_port = 35357auth_protocol = httpadmin_password = HEAT_PASS[ec2_authtoken]auth_uri = http://controller:5000/v2.0keystone_ec2_uri = http://controller:5000/v2.0/ec2tokens
now registering the heat and cloudformations API with keystone so that other openstack services can locate these APIs.
- $ keystone service-create --name=heat --type=orchestration \
- --description="Orchestration"
- $ keystone endpoint-create \
- --service-id= <service_id from above> \
- --publicurl=http://controller:8004/v1/%\(tenant_id\)s \
- --internalurl=http://controller:8004/v1/%\(tenant_id\)s \
- --adminurl=http://controller:8004/v1/%\(tenant_id\)s
Now registering the service and creating the endpoints for heat-cfn
- $ keystone service-create --name=heat-cfn --type=cloudformation \
- --description="Orchestration CloudFormation"
- $ keystone endpoint-create \
- --service-id=<service_id from above> \
- --publicurl=http://controller:8000/v1 \
- --internalurl=http://controller:8000/v1 \
- --adminurl=http://controller:8000/v1
Now starting all these services and ensuring that they will start in case of a reboot.
- # service openstack-heat-api start
- # service openstack-heat-api-cfn start
- # service openstack-heat-engine start
- # chkconfig openstack-heat-api on
- # chkconfig openstack-heat-api-cfn on
- # chkconfig openstack-heat-engine on
Verifying the installation
After having sourced the credentials
We will be using this hello_world yaml template and place it in the home folder of controller and run the following controls
- # 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
- resources:
- my_instance:
- # 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_ip:
- description: The IP address of the deployed instance
- value: { get_attr: [my_instance, PublicIp] }
And run the following command to check if all is well on the template file that is being fed.
- heat stack-create teststack --template-file=test1.yaml
in case there is a problem with the template file, the following error shows up
ERROR: 'unicode' object has no attribute 'iteritems'
Now for the magic of openstack to work
- heat stack-update mystack --template-file=hello_world.yaml --parameters="KeyName=mykey;InstanceType=m1.large;ImageId=4e443a9c-40d7-4700-8fd4-6ef42e4e3792"
Other helpful commands in heat
- heat stack-create mystack --template-file=hello_world.yaml --parameters="KeyName=mykey;InstanceType=m1.small;ImageId=4e443a9c-40d7-4700-8fd4-6ef42e4e3792"
# This is a hello world HOT template just defining a single compute instance
+--------------------------------------+------------+--------------------+----------------------+
| id | stack_name | stack_status | creation_time |
+--------------------------------------+------------+--------------------+----------------------+
| 022888cf-4bcd-4335-aaaa-6b0e8f712a55 | mystack | CREATE_IN_PROGRESS | 2014-06-05T05:58:40Z |
+--------------------------------------+------------+--------------------+----------------------+
- heat stack-list
+--------------------------------------+------------+-----------------+----------------------+
| id | stack_name | stack_status | creation_time |
+--------------------------------------+------------+-----------------+----------------------+
| 022888cf-4bcd-4335-aaaa-6b0e8f712a55 | mystack | CREATE_COMPLETE | 2014-06-05T05:58:40Z |
+--------------------------------------+------------+-----------------+----------------------+
- heat stack-show mystack
+----------------------+--------------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------+
| capabilities | [] |
| creation_time | 2014-06-05T05:58:40Z |
| 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 | 022888cf-4bcd-4335-aaaa-6b0e8f712a55 |
| notification_topics | [] |
| outputs | [ |
| | { |
| | "output_value": "10.0.0.4", |
| | "description": "The IP address of the deployed instance", |
| | "output_key": "instance_ip" |
| | } |
| | ] |
| parameters | { |
| | "AWS::StackName": "mystack", |
| | "ImageId": "4e443a9c-40d7-4700-8fd4-6ef42e4e3792", |
| | "AWS::StackId": "arn:openstack:heat::02e0307cf9cd448f8039afd61498d48b:stacks/mystack/022888cf-4bcd-4335-aaaa-6b0e8f712a55", |
| | "KeyName": "mykey", |
| | "AWS::Region": "ap-southeast-1", |
| | "InstanceType": "m1.small" |
| | } |
| stack_name | mystack |
| 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-06-05T05:59:40Z |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------+
- heat resource-list mystack
+---------------+--------------------+-----------------+----------------------+
| resource_name | resource_type | resource_status | updated_time |
+---------------+--------------------+-----------------+----------------------+
| my_instance | AWS::EC2::Instance | CREATE_COMPLETE | 2014-06-05T05:59:40Z |
+---------------+--------------------+-----------------+----------------------+
- [root@controller ~]# heat resource-show mystack my_instance
+------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
# This is a hello world HOT template just defining a single compute instance
+------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| description | |
| logical_resource_id | my_instance |
| physical_resource_id | 3eba3496-fb77-474f-9c04-1663fda8d958 |
| required_by | |
| resource_name | my_instance |
| resource_status | CREATE_COMPLETE |
| resource_status_reason | state changed |
| resource_type | AWS::EC2::Instance |
| updated_time | 2014-06-05T05:59:40Z |
+------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
- heat resource-metadata mystack my_instance
{}
- heat event-list mystack
+---------------+----+------------------------+--------------------+----------------------+
| resource_name | id | resource_status_reason | resource_status | event_time |
+---------------+----+------------------------+--------------------+----------------------+
| my_instance | 1 | state changed | CREATE_IN_PROGRESS | 2014-06-05T05:58:40Z |
| my_instance | 2 | state changed | CREATE_COMPLETE | 2014-06-05T05:59:40Z |
+---------------+----+------------------------+--------------------+----------------------+
- heat stack-update mystack --template-file=hello_world.yaml --parameters="KeyName=mykey;InstanceType=m1.large;ImageId=4e443a9c-40d7-4700-8fd4-6ef42e4e3792"
+--------------------------------------+------------+--------------------+----------------------+
| id | stack_name | stack_status | creation_time |
+--------------------------------------+------------+--------------------+----------------------+
| 022888cf-4bcd-4335-aaaa-6b0e8f712a55 | mystack | UPDATE_IN_PROGRESS | 2014-06-05T05:58:40Z |
+--------------------------------------+------------+--------------------+----------------------+
- heat event-list mystack
+---------------+----+-------------------------------------------------------+--------------------+----------------------+
| resource_name | id | resource_status_reason | resource_status | event_time |
+---------------+----+-------------------------------------------------------+--------------------+----------------------+
| my_instance | 1 | state changed | CREATE_IN_PROGRESS | 2014-06-05T05:58:40Z |
| my_instance | 2 | state changed | CREATE_COMPLETE | 2014-06-05T05:59:40Z |
| my_instance | 3 | state changed | UPDATE_IN_PROGRESS | 2014-06-05T06:14:19Z |
| my_instance | 4 | Error: Resizing to 'm1.large' failed, status 'ACTIVE' | UPDATE_FAILED | 2014-06-05T06:14:21Z |
+---------------+----+-------------------------------------------------------+--------------------+----------------------+