How to create and deploy a basic Heat template
Overview
This article provides a basic Heat Orchestration template that creates a Heat stack.
This template will create the following and connect them up:
A network
A static IP
A router
An instance
A floating IP
A volume
The Heat template
Note
The template must be in yaml format and be saved with the .yaml file extension. You should also make sure that you use the correct indentation.
heat_template_version: 2016-10-14
parameters:
flavor:
type: string
description: I am using the smallest flavor available because i'll be spinning up a cirros instance. You can use an environment file to override the defaults.
default: t1.tiny
constraints:
- custom_constraint: nova.flavor
image:
type: string
description: This uses a cirros image but you can create an environment file to change the default values.
default: cirros
constraints:
- custom_constraint: glance.image
heat_volume_size:
type: number
label: Volume Size (GB)
description: External Volume Size in GB
default: 1
resources:
heat_volume:
type: OS::Cinder::Volume
properties:
size: { get_param: heat_volume_size }
heat_volume_attachment:
type: OS::Cinder::VolumeAttachment
properties:
volume_id: { get_resource: heat_volume }
instance_uuid: { get_resource: heat_server }
heat_network:
type: OS::Neutron::Net
properties:
admin_state_up: true
name: heat_network
heat_network_subnet:
type: OS::Neutron::Subnet
properties:
network: { get_resource: heat_network }
cidr: "10.1.1.0/24"
dns_nameservers: ["8.8.8.8"]
gateway_ip: "10.1.1.1"
ip_version: 4
heat_router:
type: OS::Neutron::Router
properties:
external_gateway_info: { network: internet }
name: heat_router
heat_router_interface:
type: OS::Neutron::RouterInterface
properties:
router_id: { get_resource: heat_router }
subnet: { get_resource: heat_network_subnet }
heat_server_port:
type: OS::Neutron::Port
properties:
network: { get_resource: heat_network }
fixed_ips:
- subnet_id: { get_resource: heat_network_subnet }
heat_server:
type: OS::Nova::Server
properties:
name: heat_server
flavor: { get_param: flavor }
image: { get_param: image }
networks:
- port: { get_resource: heat_server_port}
heat_server_public_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network: "internet"
heat_server_ip_assoc:
type: OS::Neutron::FloatingIPAssociation
properties:
floatingip_id: { get_resource: heat_server_public_ip }
port_id: { get_resource: heat_server_port }
outputs:
heat_server_public_ip:
description: IP Address of the deployed heat_server instance
value: { get_attr: [ heat_server_public_ip, floating_ip_address ]}
Deploying the stack
Note
You must source your RC file before you run the commands below.
Create a stack by running the following command in the OpenStack CLI:
openstack stack create -t <template name> <stack name>
For example, for the template above, run:
$ openstack stack create -t basic-stack.yaml basic-stack
This command will return the following:
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| id | 6be269ec-d22f-4cf0-bf04-df71cc6dcf75 |
| stack_name | basic-stack |
| description | No description |
| creation_time | 2019-02-12T15:58:20Z |
| updated_time | None |
| stack_status | CREATE_IN_PROGRESS |
| stack_status_reason | Stack CREATE started |
+---------------------+--------------------------------------+
Next steps
This article demonstrated how to create a basic Heat template. You should now be able to create your own templates.
If you want to create a template from your existing environment, you can use a tool like Flame that converts an existing environment into a Heat template. For more information, see https://github.com/openstack/flame
The following document provides more options for configuring and creating Heat templates when using UKCloud for OpenStack:
Heat Orchestration Template (HOT) specification
Feedback
If you find a problem with this article, click Improve this Doc to make the change yourself or raise an issue in GitHub. If you have an idea for how we could improve any of our services, send an email to feedback@ukcloud.com.