Using the OpenSDN Heat Template¶
- date:
2020-03-31
Heat is the orchestration engine of the OpenStack program. Heat enables launching multiple cloud applications based on templates that are comprised of text files.
Introduction to Heat¶
A Heat template describes the infrastructure for a cloud application, such as networks, servers, floating IP addresses, and the like, and can be used to manage the entire life cycle of that application.
When the application infrastructure changes, the Heat templates can be modified to automatically reflect those changes. Heat can also delete all application resources if the system is finished with an application.
Heat templates can record the relationships between resources, for example, which networks are connected by means of policy enforcements, and consequently call OpenStack REST APIs that create the necessary infrastructure, in the correct order, needed to launch the application managed by the Heat template.
Heat Architecture¶
Heat is implemented by means of Python applications, including the following:
heat-client
—The CLI tool that communicates with theheat-api
application to run Heat APIs.heat-api
—Provides an OpenStack native REST API that processes API requests by sending them to the Heat engine over remote procedure calls (RPCs).heat-engine
—Responsible for orchestrating the launch of templates and providing events back to the API consumer.
Support for Heat Version 2 Resources¶
Starting with OpenSDN Release 3.0.2, OpenSDN Heat resources and
templates are autogenerated from the OpenSDN schema, using Heat Version
2 resources. OpenSDN Release 3.0.2 is the minimum required version for
using Heat with OpenSDN in 3.x releases. The OpenSDN Heat Version 2
resources are of the following hierarchy:
OS::ContrailV2::<ResourceName>
.
The generated resources and templates are part of the OpenSDN Python package, and are located in the following directory in the target installation:
/usr/lib/python2.7/dist-packages/vnc_api/gen/heat/
The heat/
directory has the following subdirectories:
resources/
—Contains all the resources for the contrail-heat plugin, which runs in the context of the Heat engine service.templates/
—Contains sample templates for each resource. Each sample template presents every possible parameter in the schema. Use the sample templates as a reference when you build up more complex templates for your network design.env/
—Contains the environment for input to each template.
The following contains a list of all the generated plug-in resources that are supported by contrail-heat :
https://github.com/opensdn-io/tf-heat-plugin/tree/master/contrail_heat/new_templates
Deprecation of Heat Version 1 Resources¶
Heat Version 1 resources within the hierarchy
OS::Contrail::<ResourceName>
are being deprecated, and you should
not create new service templates using the Heat Version 1 templates.
Heat Version 2 with Service Templates and Port Tuple Sample Workflow¶
With OpenSDN service templates Version 2, the user can create ports and bind them to a virtual machine (VM)-based service instance, by means of a port-tuple object. All objects created with the Version 2 service template are directly visible to the OpenSDN Heat engine, and are directly managed by Heat.
The following shows the basic workflow steps for creating a port tuple and service instance that will be managed by Heat:
Create a service template. Select 2 in the Version field.
Create a service instance for the service template just created.
Create a port-tuple object.
Create ports, using Nova VM launch or without a VM launch.
Label each port as left, right, mgmt, and so on, and add the ports to the port-tuple object.
Use a unique label for each of the ports in a single port tuple. The labels named left and right are used for forwarding.
Link the port tuple to a service instance.
Launch the service instance.
Example: Creating a Service Template Using Heat¶
The following is an example of how to create a service template using Heat.
Define a template to create the service template.
service_template.yaml heat_template_version: 2013-‐05-‐23 description: > HOT template to create a service template parameters: name: type: string description: Name of service template mode: type: string description: service mode type: type: string description: service type image: type: string description: Name of the image flavor: type: string description: Flavor service_interface_type_list: type: string description: List of interface types shared_ip_list: type: string description: List of shared ip enabled-‐disabled static_routes_list: type: string description: List of static routes enabled-‐disabled resources: service_template: type: OS::ContrailV2::ServiceTemplate properties: name: { get_param: name } service_mode: { get_param: mode } service_type: { get_param: type } image_name: { get_param: image } flavor: { get_param: flavor } service_interface_type_list: { "Fn::Split" : [ ",", Ref: service_interface_type_list ] } shared_ip_list: { "Fn::Split" : [ ",", Ref: shared_ip_list ] } static_routes_list: { "Fn::Split" : [ ",", Ref: static_routes_list ] } outputs: service_template_fq_name: description: FQ name of the service template value: { get_attr: [ service_template, fq_name] } }
Create an environment file to define the values to put in the variables in the template file.
service_template.env parameters: name: contrail_svc_temp mode: transparent type: firewall image: cirros flavor: m1.tiny service_interface_type_list: management,left,right,other shared_ip_list: True,True,False,False static_routes_list: False,True,False,False
Create the Heat stack by launching the template and the environment file, using the following command:
heat stack create stack1 –f service_template.yaml –e service_template.env
OR use this command for recent versions of OpenStack
openstack stack create -e <env-file-name> -t <template-file-name> <stack-name>