How to create a Cloud Application Template from existing infrastructure
Cloud Application Templates (CATs) are descriptions of the infrastructure and software configuration needed to deploy a cloud application. They are based on the TOSCA Simple Profile in YAML standard.
The easiest way to create a CAT is by exporting an infrastructure that you created in the Orchestrator.
Prerequisites
- You need to have one or more servers created in Multi-Cloud Orchestrator and configured with the corresponding template. In addition, you have created all the related infrastructure, like VPC, subnets, floating IPs, firewalls, etc.
Note: The export will not include infrastructure that is not directly related to the server. If you need additional infrastructure in the CAT, you will have to define it manually using TOSCA.
You need some basic knowledge of TOSCA and in particular, familiarity with YAML.
You need a tool to compress and uncompress a ZIP file, and a text editor with YAML support.
Export cloud infrastructure
Go to Compute -> Servers
Select one or more servers that you want to export. The button "Actions for x Item(s)" appears.
Press this button and select "Export to csar file".
Once the export finished, you will be able to download the file to your local file system by pressing "Download csar file".
Edit csar file contents
Unzip the resulting csar file (it is a standard ZIP archive).
Open the file definitions/main.yaml in your favourite text editor
Below the first line, add a YAML mapping with key metadata and nested mappings for keys templatename, templateauthor, and template_version.
tosca_definitions_version: tosca_simple_yaml_1_0 metadata: template_name: My first CAT template_author: John Doe template_version: 0.1 topology_template:
Decide, which aspects of your exported infrastructure should vary with each deployment and make them input parameters of the CAT, by adding a nested mapping with key inputs to the topologytemplate mapping. In the example below, we define two parameters region and serverplan:
topology_template: inputs: region: type: ingrammicro.orchestrator.datatypes.Region required: true description: Region in Azure/AWS metadata: order: 1 server_plan: type: ingrammicro.orchestrator.datatypes.ServerPlan required: true description: Server plan for my server metadata: dependency: region order: 2 node_templates:
Note that by choosing the appropriate types like in the example, you will get the Orchestrator to show a dropdown selection during CAT deployment. But be careful that a server plan depends on the region.
Within your nodetemplates, relationshiptemplates, and policies, make sure to replace the corresponding values by TOSCA get_input functions.
See, how in the following example, the VPC's region property and the server's region and server_plan properties make reference to the input parameter names:
node_templates: Magento: type: ingrammicro.orchestrator.nodes.network.VPC properties: cidr: 10.0.0.0/24 ip_version: 4 region: {get_input: region} attributes: {} Magento Backend: type: ingrammicro.orchestrator.nodes.Compute properties: obtain_credentials: false private: true region: {get_input: region} server_plan: {get_input: server_plan} attributes: {}
Recreate the csar file by creating a ZIP archive from the top-level folders definitions, TOSCA-Metadata, etc. Make sure that the archive has the .csar file suffix.
Test your CAT
Follow the instructions in How to deploy a cloud application from a template to deploy your CAT. Enjoy!