The custom template process is as follows:
The tool deployment template is defined and managed through the ConfigMap resource. Each template consists of the following three main parts:
Basic information includes the template name, description, tags, comments, display name, and description.
Field | Description |
---|---|
metadata.name | The unique identifier of the template resource, used to distinguish different templates in the system |
metadata.namespace | The namespace where the template resource is located, currently the UI only displays templates under the cpaas-system namespace |
metadata.labels[tools.cpaas.io/template] | Specifies the type of tool applicable to the template, for example, gitlabofficial indicates that this template is used to deploy GitLab. This value usually corresponds to the resource name of the tool instance |
metadata.labels[ui.cpaas.io/hidden] | Controls whether the template is displayed in the UI. Note that if you need to hide the product's built-in template, you need to use the skip-sync annotation in conjunction with it |
metadata.annotations[ui.cpaas.io/description.<language>] | A detailed description of the template, helping the user to understand the purpose and application scenarios of the template. <language> is the language code, supporting internationalization configuration |
metadata.annotations[ui.cpaas.io/configuration.<language>] | Technical specifications of the template, including key information such as resource requirements, storage configuration, and network access methods. <language> is the language code, supporting internationalization configuration |
metadata.annotations[skip-sync] | Controls whether the operator manages the built-in template. If the template is set with this annotation, the operator will not update the content of the template when restarting or upgrading |
Example:
The tool deployment UI provides dynamic form functionality, which can automatically generate the corresponding form interface according to the form description information in the template, simplifying the user's configuration process.
The configuration information of the dynamic form is stored in the ui.cpaas.io/descriptors
annotation, the specific format is as follows:
Field | Description |
---|---|
path | The unique identifier of the form field, used to reference the user's input value in the deployment template |
x-descriptors | Defines the properties of the form control, including label name, description text, control type, data validation rules, etc. |
Please refer to the Configure Dynamic Form section for the supported control types of the dynamic form.
The template engine is implemented based on Helm Template
and supports all Helm built-in template functions, such as string processing, mathematical operations, flow control, etc. You can use these functions to build flexible deployment templates.
The main function of the template is to replace the input parameters into the predefined template. The input parameters mainly come from two sources:
Get parameters from user input
In the template, you can use the {{ .Values.<field name> }}
syntax to get the value entered by the user. For example, if a field named domain
is defined in the form for entering the deployment domain, then in the template, you can use {{ .Values.domain }}
to reference this value.
Get parameters from k8s resources
In the template, you can use the lookup
function provided by Helm Template to get configuration information from Kubernetes resources. For example, to get the Redis connection information (such as Host, Port) from the gitlab-redis
Secret resource in the tools
namespace, you can use the lookup
function as follows:
The name of the Secret can also be entered by the user. For example, if a field named redisSecret
is defined, you can use .Values.redisSecret
to reference the Secret name entered by the user in the template.
The template supports internationalization configuration. When displayed on the UI, the corresponding name and description will be displayed according to the language selected by the user.
The supported internationalization configuration annotations include:
ui.cpaas.io/displayName.<language>
ui.cpaas.io/description.<language>
ui.cpaas.io/configuration.<language>
To configure internationalization, just add the language code at the end of the field, such as:
zh
: Display when Chinese is selecteden
: Display when English is selectedExample:
Common control types include: string, number, and drop-down box.
Control Type | Description |
---|---|
urn:alm:descriptor:com.tectonic.ui:text | String type input box |
urn:alm:descriptor:com.tectonic.ui:number | Number type input box |
urn:alm:descriptor:com.tectonic.ui:select:expression | Drop-down box |
Example:
The following variables can be used when describing the dynamic form:
${context.cluster}
: The name of the current cluster${context.namespace}
: The current namespace (the namespace where the user selects the tool to be deployed)Example:
The tool deployment template supports configuring the international display content of the control's name, description, and placeholder. By adding descriptors with language codes in the x-descriptors, the system can dynamically display the corresponding text according to the user's language preference.
The supported internationalization configuration types include:
urn:alm:descriptor:label:<language>:<name>
urn:alm:descriptor:description:<language>:<description>
urn:alm:descriptor:placeholder:<language>:<placeholder>
Where <language>
is the language code, currently supported:
zh
: Chineseen
: EnglishExample: Configure a domain input box that supports Chinese and English:
Dynamic form controls support configuring international display content. When displayed on the UI, the corresponding name and description will be displayed according to the user's language selection.
Control Field | Description |
---|---|
urn:alm:descriptor:label:<language>:<name> | Describes the name of the control - <language> is the language code, such as zh for Chinese, en for English- <name> is the name displayed by the control |
urn:alm:descriptor:description:<language>:<description> | Describes the description of the control - <language> is the language code, such as zh for Chinese, en for English- <description> is the description of the control |
urn:alm:descriptor:placeholder:<language>:<placeholder> | Describes the placeholder description of the control - <language> is the language code, such as zh for Chinese, en for English- <placeholder> is the placeholder description of the control |
The dynamic form supports validating user input. The supported validation rules are as follows:
Control Field | Description |
---|---|
urn:alm:descriptor:com.tectonic.ui:validation:minimum:<number> | Limit the minimum value of the number type field |
urn:alm:descriptor:com.tectonic.ui:validation:maximum:<number> | Limit the maximum value of the number type field |
urn:alm:descriptor:com.tectonic.ui:validation:required | Limit the field to be a required item |
urn:alm:descriptor:com.tectonic.ui:validation:pattern:<pattern> | Limit the input to meet the given regular expression |
urn:alm:descriptor:com.tectonic.ui:validation:maxLength:<number> | Limit the maximum length of the input string |
urn:alm:descriptor:com.tectonic.ui:validation:minLength:<number> | Limit the minimum length of the input string |
Example 1: Limit the value range to: 30000 ~ 32767
Example 2: Limit the string field to be required
Example 3: Limit the path entered by the user to be an absolute path
Example 4: Limit the length of the user input to 2-32 characters
The dynamic form supports dynamically loading the option list by calling the API.
Control Field | Description |
---|---|
urn:alm:descriptor:com.tectonic.ui:select:expression | Describes the control as a drop-down box |
urn:alm:descriptor:expression:props.options:api:<api> | Defines the api address to get the option data |
urn:alm:descriptor:expression:props.options:label:path:metadata.name | Defines the field of the option display name |
urn:alm:descriptor:expression:props.options:value:path:metadata.name | Defines the value field of the option |
Example: Get the Secret resource from the devops namespace of the test cluster and use metadata.name
as the display name and value of the option.
Register the custom template:
ConfigMap
) in the cpaas-system
namespace of the target cluster to complete the registration.Verify the template registration:
Create Resource
button to enter the template selection pageVerify the template content:
Create Resource
button to enter the template selection pageVerify template content:
After the tool operator is deployed, it will automatically register the built-in deployment templates in the cpaas-system
namespace of the current cluster. You can view the template content through the following path:
Management View
Cluster Management
> Resource Management
ConfigMap
template
to find the corresponding templateIf you need to hide the product's built-in template, you can add the ui.cpaas.io/hidden
label to the template resource and set it to true
. Additionally, you need to add the skip-sync
annotation; otherwise, the operator will restore the template content when restarting or upgrading.