从定义中生成表单

    对于任何通过 安装的 capability, KubeVela 会自动根据 OpenAPI v3 JSON schema 的参数列表来生成 OpenAPI v3 JSON schema,并把它储存到一个和定义对象处于同一个 的 ConfigMap 中。

    默认的 KubeVela 系统 namespacevela-system,内置的 capability 和 schema 位于此处。

    ConfigMap 命名的格式为 schema-<your-definition-name>,数据键为 openapi-v3-json-schema.

    举个例子,我们可以使用以下命令来获取 webservice 的JSON schema。

    1. $ kubectl get configmap schema-webservice -n vela-system -o yaml
    2. kind: ConfigMap
    3. metadata:
    4. namespace: vela-system
    5. data:
    6. openapi-v3-json-schema: '{"properties":{"cmd":{"description":"Commands to run in
    7. the container","items":{"type":"string"},"title":"cmd","type":"array"},"cpu":{"description":"Number
    8. of CPU units for the service, like `0.5` (0.5 CPU core), `1` (1 CPU core)","title":"cpu","type":"string"},"env":{"description":"Define
    9. arguments by using environment variables","items":{"properties":{"name":{"description":"Environment
    10. variable name","title":"name","type":"string"},"value":{"description":"The value
    11. a source the value of this var should come from","properties":{"secretKeyRef":{"description":"Selects
    12. a key of a secret in the pod''s namespace","properties":{"key":{"description":"The
    13. key of the secret to select from. Must be a valid secret key","title":"key","type":"string"},"name":{"description":"The
    14. name of the secret in the pod''s namespace to select from","title":"name","type":"string"}},"required":["name","key"],"title":"secretKeyRef","type":"object"}},"required":["secretKeyRef"],"title":"valueFrom","type":"object"}},"required":["name"],"type":"object"},"title":"env","type":"array"},"image":{"description":"Which
    15. image would you like to use for your service","title":"image","type":"string"},"port":{"default":80,"description":"Which
    16. port do you want customer traffic sent to","title":"port","type":"integer"}},"required":["image","port"],"type":"object"}'
    • 对于基于 CUE 的定义:parameter CUE 模板中的关键词。

    渲染表单

    你可以通过 或者 React JSON Schema form 渲染上述 schema 到表单中并轻松地集成到你的仪表盘中。

    以下是使用 渲染的表单:

    下一步

    根据设计,KubeVela 支持多种方法来定义 schematic。因此,我们将在接下来的文档来详细解释 .schematic 字段。