Prepare instance template files
StackState Self-hosted v5.1.x
When preparing an instance specific template file, keep in mind that you will use some identifiers that point to the shared template file. It's highly recommended to prepare your shared template first.
This file should include configuration blocks for the DataSource used by this instance, Topology information, QueryViews, etc. You can identify them in your export .stj file by identifier with instance entry, for example "urn:stackpack:{{StackPackName}}:instance:{{instanceId}}:sync:test". However, this file also requires pointers to functions, Component templates, and Relation templates from the shared template file as in the below example:
The file should also include mapping functions called componentActions from the shared-template file to execute on the instance nodes:
Synchronizations and componentActions mappings
componentActions mappings{
"_type": "Sync",
"name": "Test",
"identifier": "urn:stackpack:{{StackPackName}}:instance:{{instanceId}}:sync:test",
"relationActions": [],
"extTopology": -142,
"topologyDataQuery":
{
"_type": "Sts.StsTopologyElementsQuery",
"relationIdExtractorFunction": {{get "urn:stackpack:{{StackPack name}}:shared:idextractor-function:test-relation-id-extractor"}},
"componentIdExtractorFunction": {{get "urn:stackpack:{{StackPack name}}:shared:idextractor-function:test-component-id-extractor"}},
"id": -191,
"consumerOffsetStartAtEarliest": false
},
"componentActions":
[
{
"_type": "SyncActionCreateComponent",
"templateFunction": {{get "urn:stackpack:{{StackPackName}}:shared:component-template-function:exchange-service-template"}},
"id": -190,
"mergeStrategy": "MergePreferTheirs",
"type": "exchange_service"
}
],
"id": -2,
"defaultComponentAction":
{
"_type": "SyncActionCreateComponent",
"templateFunction": {{get "urn:stackpack:{{StackPackName}}:shared:component-template-function:exchange-component-template"}},
"id": -1,
"mergeStrategy": "MergePreferTheirs",
"type": "default_component_mapping"
},
"defaultRelationAction":
{
"_type": "SyncActionCreateRelation",
"templateFunction": {{get "urn:stackpack:{{StackPackName}}:shared:relation-template-function:test-relation-template"}},
"id": -188,
"mergeStrategy": "MergePreferTheirs",
"type": "default_relation_mapping"
}
},After getting Synchronizations and Mappings from the shared-template into your instance-specific file, you can start looking for instance-specific blocks in the STJ export and copy them to your instance-specific template. You can quickly identify instance specific blocks, as their Identifier contains instance:{{instanceId}} segment.
DataSources
Topology Information
QueryViews
Example of an instance template file:
The next step is: Prepare a multi-instance provisioning script
Last updated