第4章 Kamelets 参照

4.1. Kamelet 構造

通常、Kamelet は YAML ドメイン固有の言語でコーディングされます。ファイル名の接頭辞は、Kamelet の名前です。たとえば、FTP sink という名前の Kamelet のファイル名は ftp-sink.kamelet.yaml です。

OpenShift では、Kamelet は、(ファイル名ではなく) Kamelet の名前を表すリソースであることに注意してください。

概略では、Kamelet リソースは以下を説明します。

  • Kamelet の ID、および Kamelet のタイプ (sourcesinkaction) 等のその他の情報が含まれるメタデータセクション。
  • Kamelet の設定に使用できるパラメーターセットが含まれる定義 (JSON-schema 仕様)。
  • Kamelet によって想定される入出力に関する情報が含まれるオプションの types セクション。
  • Kamelet の実装を定義する YAML DSL の Camel フロー。

以下の図は、Kamelet とその部分の例を示しています。

Kamelet 構造の例

telegram-text-source.kamelet.yaml
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: telegram-source 1
  annotations: 2
    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: 3
    camel.apache.org/kamelet.type: "source"
spec:
  definition: 4
    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: 5
    out:
      mediaType: application/json
  dependencies:
  - "camel:jackson"
  - "camel:kamelet"
  - "camel:telegram"
  flow: 6
    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"
  1. Kamelet ID: Kamelet を参照する場合は Camel K インテグレーションでこの ID を使用します。
  2. アイコンなどのアノテーションは、Kamelet の表示機能を提供します。
  3. ラベルを使用すると、ユーザーは Kamelets にクエリーできます (例: ソース、シンク、またはアクションにより)。
  4. JSON-schema 仕様形式の Kamelet およびパラメーターの説明。
  5. 出力のメディアタイプ (スキーマを含む)。
  6. Kamelet の動作を定義するルートテンプレート。