Infra As Code Templates
Introduction
Infra As Code Templates contain instructions on how cluster, networks, firewall, load balancers ... should be created and interconnected with one another to set up and run a complete deployment.
SOAJS provides the mechanism to create/import templates and then use them when creating environment to set up the infrastructure clusters on which the environment should be deployed.
1- Template Meta Information
Templates are represented by either a JSON configuration object or Text Content in which the instructions on how to setup an infrastructure is provided and are bound to the driver that executes them.
Some templates are stored in the database while others require to be stored on the provider itself; the location of the template is also depicted by the cloud provider driver that renders the template.
Cloud Provider | Template Location | Schema Type | Driver |
---|---|---|---|
AWS | Remote ( at infra provider ) | Text | GKE |
Local ( in the database ) | JSON | Cloud Formation |
2- Template Inputs
While creating or modifying a template, you can expose some of its fields and give the user the ability to change them.
For example if you are creating a template that creates a cluster of multiple virtual machines where these machines should have the exact same flavor, you can expose the number of machines to create and the flavor to create them from.
To do that, simply fill in the JSON form inputs schema based on the SOAJS Form Library and then during deployment, when you pick the template, SOAJS will load the JSON render it and display extra form inputs for the user to fill.
Template JSON Schema GKE | Template JSON Inputs Schema | Template During Deployment |
---|---|---|
During Deployment, select the template and SOAJS will render the inputs in a UI form for you to fill. |
3- Template Inputs Display
In addition to exposing template inputs for the user to fill, you can also configure how the summary should look like after the user fills the form and click submit.
Basically the summary is a grid that contains the most important fields and values that you want the user to remember after he fills the form.
The inputs display also based on a JSON configuration, the below snippet contains details and an example on how the image on the right was configured:
{ "%columnMetaName%" : { "label": "%Column Display Label%", "fields": [ { "name": "%fieldMetaNameAsPerTemplateInputs%", "label": "%Field Label%" } ] } }
Template Inputs Display Summary |
---|
4- Template Inputs Validation
Template inputs can be validate to ensure their values prior to invoking cloud providers to create your cluster.
While creating the template, along with the ability to expose some of the inputs, and configure their display, you can also supply a validation schema that follows the open standard json schema.
SOAJS will use this schema when the user picks this template and fills the form to validate if the values provided are correct or not and highlight the errors.
The following sample demonstrates the validation schema to use if the template exposes 2 inputs: worker nodes number & worker node flavor.
{ //validation for number of worker nodes depicts that the value must be provided as a number between 1 and 5 "workernodes": { "type": "number", "min": 1, "max": 5, "required": true }, //validation for worker flavor ( machine type ) depicts that the value must be provided as a string but restricted to one of 3 values "workerflavor": { "type": "string", "enum": [ "n1-standard-2", "n1-standard-4", "n1-standard-8" ], "required": true } }
You can learn more about the validation schema properties, attributes to use and other configuration on the official website of json schema.