Infrastructure resource
Infrastructure resources are custom objects that are not part of the standard Console supported resources. They can be managed from the dedicated section of the Console Design area.
To create or edit an infrastructure resource, you need to provide a manifest, whose resources
property should adhere to the following JSON schema.
The JSON schemas of the infrastructure resource resources and of the full infrastructure resource manifest are available on GitHub.
- Schema Viewer
- Raw JSON Schema
- Example
{
"$id": "catalog-infrastructure-resource-resources.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"description": "Resources of Catalog items of type custom-resource",
"properties": {
"annotations": {
"items": {
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
},
"attributes": {
"additionalProperties": {
"properties": {
"type": {
"enum": [
"input"
],
"type": "string"
}
},
"type": "object"
},
"description": "Attributes to be used to generate the form to manage the custom resource",
"type": "object"
},
"generator": {
"properties": {
"configurationBaseFolder": {
"type": "string"
},
"templates": {
"items": {
"properties": {
"engine": {
"description": "The template engine used for generating the file (default is `mustache`)",
"enum": [
"mustache"
],
"type": "string"
},
"fileExtension": {
"description": "The extension of the file to generate. If not set, default is .yml",
"type": "string"
},
"folderName": {
"description": "The name of the folder where the file will be created, below the configurationBaseFolder",
"type": "string"
},
"name": {
"type": "string"
},
"template": {
"type": "string"
}
},
"required": [
"template",
"name"
],
"type": "object"
},
"type": "array"
},
"type": {
"enum": [
"template"
],
"type": "string"
}
},
"required": [
"type",
"templates"
],
"type": "object"
},
"labels": {
"items": {
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
},
"meta": {
"properties": {
"apiVersion": {
"type": "string"
},
"kind": {
"type": "string"
}
},
"type": "object"
},
"name": {
"minLength": 1,
"type": "string"
},
"runtime": {
"description": "The object used to view the status of your current Kubernetes resources directly in the Console Runtime section",
"additionalProperties": false,
"properties": {
"resourceId": {
"description": "The plural name for the infrastructure resource definition",
"type": "string"
},
"type": {
"description": "The type of the infrastructure resource. At the moment the only supported type by the Catalog is \"kubernetes\"",
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
},
"service": {
"properties": {
"archive": {
"description": "URL for an tar.gz archive to be used to generate a new repository",
"type": "string"
}
},
"type": "object"
},
"jsonSchema": {
"type": "object"
},
"spec": {
"type": "object"
}
},
"title": "Catalog infrastructure resource resources",
"type": "object",
"examples": [
{
"name": "ExternalOrchestratorLambda",
"meta": {
"kind": "ExternalOrchestratorLambda",
"apiVersion": "custom-generator.console.mia-platform.eu/v1"
},
"spec": {
"code": "the code"
},
"generator": {
"type": "template",
"configurationBaseFolder": "base-folder-name",
"templates": [
{
"template": "this template can take some values from the spec, such as %spec.code%",
"name": "template-name",
"fileExtension": "json",
"folderName": "template-folder-name"
}
]
}
},
{
"name": "sleepInfo",
"meta": {
"apiVersion": "kube-green.com/v1alpha1",
"kind": "SleepInfo"
},
"spec": {
"sleepAt": "20:00",
"timeZone": "Europe/Rome",
"weekdays": "1-5"
},
"runtime": {
"type": "kubernetes",
"resourceId": "sleepinfos"
}
}
]
}
{
"name": "ExternalOrchestratorLambda",
"meta": {
"kind": "ExternalOrchestratorLambda",
"apiVersion": "custom-generator.console.mia-platform.eu/v1"
},
"spec": {
"code": "the code"
},
"generator": {
"type": "template",
"configurationBaseFolder": "base-folder-name",
"templates": [
{
"template": "this template can take some values from the spec, such as %spec.code%",
"name": "template-name",
"fileExtension": "json",
"folderName": "template-folder-name"
}
]
}
}
Monitor a Custom Kubernetes Resource in the Runtime area
If you've upgraded to Console release v13.3.0
, you can now view the status of your Current Kubernetes Resources directly in the Runtime section. To enable this feature, publish a new version of your infrastructure resource that include the fields runtime
.
Generate dynamic form to customize validation
If you have upgraded the Console to version v13.6.1
, you can now generate a dynamic form. This documentation serves as a guide for users to understand and effectively utilize the dynamic form fields generated from a JSON schema. By following the examples and descriptions provided, users can create forms that are both functional and user-friendly, ensuring a smooth data entry experience.
In the next versions of the Console we want to add dynamic form generation also in the details section.
The Frontend of the Console generate the Form using the roles below:
Supported JSON Schema Types
- type Object
- type Array
- type String
- type Boolean
- type Integer
- type Number
Object field
Visualized as Editor
```json
{
"jsonSchema": {
"type": "object",
"required": ["mirroring"],
"properties" {
"mirroring": { "type": "object", "description": "Mirroring defines the Mirroring service configuration" }
}
}
}
```
Validation
The editor generated from this type can validate with ajv library the sub schema used to fields
```json
{
"jsonSchema": {
"type": "object",
"required": ["mirroring"],
"properties" {
"mirroring": {
"type": "object",
"additionalProperties": false,
"required": ["name"],
"properties": {
"name": { "type": "string" }
}
}
}
}
}
```
Array field
Visualized as Editor
```json
{
"jsonSchema": {
"type": "object",
"properties": {
"services": {
"items": {
"additionalProperties": false,
"properties": {
"healthCheck": {
"additionalProperties": false,
"properties": {
"followRedirects": { "type": "boolean" },
}
}
}
}
}
}
}
}
```
Validation
The editor generated from this type can validate with ajv library the sub schema used to fields
```json
{
"jsonSchema": {
"type": "object",
"properties": {
"services": {
"items": {
"type": "object",
"properties": {
"healthCheck": {
"type": "object",
"properties": {
"followRedirects": { "type": "boolean" },
}
}
}
}
}
}
}
}
```
String type
Used for textual input. It can include various validations such as minimum and maximum length. When using a string field, ensure that the input meets the specified length requirements.
```json
{
"jsonSchema": {
"type": "object",
"properties": {
"type": "string",
"minLength": 5,
"maxLength": 100,
"description": "Enter your full name."
}
}
}
```
The boolean type is used for true/false values. This is typically represented as a switch in the form.
```json
{
"jsonSchema": {
"type": "object",
"properties": {
"boolean": {
"type": "boolean",
"description": "Do you agree to the terms and conditions?"
}
}
}
}
```
Integer type
Specifically for whole numbers. It behaves similarly to the number type but restricts input to integers.
```json
{
"jsonSchema": {
"type": "object",
"properties": {
"integer": {
"type": "integer",
"minimum": 1,
"maximum": 10,
"description": "Enter an integer between 1 and 10."
}
}
}
}
```
Number type
Used for numerical input, which can include both integers and floating-point numbers.
```json
{
"jsonSchema": {
"type": "object",
"properties": {
"number": {
"type": "number",
"minimum": 0,
"maximum": 100,
"description": "Enter a value between 0 and 100"
}
}
}
}
```
Unsupported JSON Schema Features
While our dynamic form fields support a wide range of JSON schema features, there are certain features that are not supported. Additionally, being aware of the unsupported features will help users avoid potential issues when designing their schemas. Below is a list of unsupported features:
- $ref: Reference to external schemas
- oneOf: Validation against one of the specified schemas
- allOf: Validation against all of the specified schemas
- anyOf: Validation against any of the specified schemas
- not: Validation against the negation of the specified schema
- string format: Specific string formats such as email, date, etc
- number exclusiveMinimum and exclusiveMaximum: Exclusive range validation for numbers
- dependencies: Conditional validation based on the presence of other fields
Partially supported JSON Schema Features
- additionalProperties: Validation of additional properties work only for types array or object in the schema
- patternProperties: Validation of properties matching a specific pattern