第 4 章 Kamelets 参考
4.1. Kamelet 结构 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Kamelet 通常以特定于 YAML 域特定语言进行编码。文件名前缀是 Kamelet 的名称。例如,名为 FTP sink 的 Kamelet 具有文件名 ftp-sink.kamelet.yaml。
请注意,在 OpenShift 中,K Kamelet 是一个显示 Kamelet 名称(而不是文件名)的资源。
在高级别上,KKmelet 资源描述:
-
包含 Kamelet 和其他信息的 ID 的 metadata 部分,如 Kamelet 类型(
源、sink或action)。 - 一个定义(JSON-schema 规格),其中包含一组可用于配置 Kamelet 的参数。
-
一个可选
类型部分,其中包含 Kamelet 所期望的输入和输出信息。 - YAML DSL 中的 Camel 模板,用于定义 Kamelet 实施。
下图显示了 Kamelet 及其部分的示例。
Kamelet 结构示例
telegram-text-source.kamelet.yaml
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
name: telegram-source
annotations:
camel.apache.org/catalog.version: "master-SNAPSHOT"
camel.apache.org/kamelet.icon: "data:image/..."
camel.apache.org/provider: "Red Hat"
camel.apache.org/kamelet.group: "Telegram"
labels:
camel.apache.org/kamelet.type: "source"
spec:
definition:
title: "Telegram Source"
description: |-
Receive all messages that people send to your telegram bot.
To create a bot, contact the @botfather account using the
Telegram app.
The source attaches the following headers to the messages:
- chat-id / ce-chatid: the ID of the chat where the
message comes from
required:
- authorizationToken
type: object
properties:
authorizationToken:
title: Token
description: The token to access your bot on Telegram, that you
can obtain from the Telegram "Bot Father".
type: string
format: password
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:password
types:
out:
mediaType: application/json
dependencies:
- "camel:jackson"
- "camel:kamelet"
- "camel:telegram"
template:
from:
uri: telegram:bots
parameters:
authorizationToken: "{{authorizationToken}}"
steps:
- set-header:
name: chat-id
simple: "${header[CamelTelegramChatId]}"
- set-header:
name: ce-chatid
simple: "${header[CamelTelegramChatId]}"
- marshal:
json: {}
- to: "kamelet:sink"
- Kamelet ID - 在您想要引用 Kamelet 时使用此 ID 在 Camel K 集成中。
- 注解,如图标,为 Kamelet 提供显示功能。
- 通过标签,用户可以查询 Kamelets (例如,按 kind: "source"、"sink" 或 "action")
- JSON-schema 规范格式的 Kamelet 和参数的描述。
- 输出的介质类型(可以包含架构)。
- 定义 Kamelet 行为的路由模板。