diff --git a/docs/modules/ROOT/assets/images/kamelets/mongodb-sink.svg b/docs/modules/ROOT/assets/images/kamelets/mongodb-sink.svg new file mode 100644 index 000000000..bf6e1f554 --- /dev/null +++ b/docs/modules/ROOT/assets/images/kamelets/mongodb-sink.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 88499f524..31ab73dcf 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -80,6 +80,7 @@ * xref:ROOT:message-timestamp-router-action.adoc[image:kamelets/message-timestamp-router-action.svg[] Message Timestamp Router Action] * xref:ROOT:minio-sink.adoc[image:kamelets/minio-sink.svg[] Minio Sink] * xref:ROOT:minio-source.adoc[image:kamelets/minio-source.svg[] Minio Source] +* xref:ROOT:mongodb-sink.adoc[image:kamelets/mongodb-sink.svg[] MongoDB Sink] * xref:ROOT:mongodb-source.adoc[image:kamelets/mongodb-source.svg[] MongoDB Source] * xref:ROOT:mqtt-source.adoc[image:kamelets/mqtt-source.svg[] MQTT Source] * xref:ROOT:mysql-sink.adoc[image:kamelets/mysql-sink.svg[] MySQL Sink] diff --git a/docs/modules/ROOT/pages/mongodb-sink.adoc b/docs/modules/ROOT/pages/mongodb-sink.adoc new file mode 100644 index 000000000..d3f517a1f --- /dev/null +++ b/docs/modules/ROOT/pages/mongodb-sink.adoc @@ -0,0 +1,138 @@ +// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT += image:kamelets/mongodb-sink.svg[] MongoDB Sink + +*Provided by: "Apache Software Foundation"* + +*Support Level for this Kamelet is: "Preview"* + +Send documents to MongoDB. + +This Kamelet expects a JSON as body. + +== Configuration Options + +The following table summarizes the configuration options available for the `mongodb-sink` Kamelet: +[width="100%",cols="2,^2,3,^2,^2,^3",options="header"] +|=== +| Property| Name| Description| Type| Default| Example +| *collection {empty}* *| MongoDB Collection| Sets the name of the MongoDB collection to bind to this endpoint.| string| | +| *database {empty}* *| MongoDB Database| Sets the name of the MongoDB database to target.| string| | +| *hosts {empty}* *| MongoDB Hosts| Comma separated list of MongoDB Host Addresses in host:port format.| string| | +| *password {empty}* *| MongoDB Password| User password for accessing MongoDB.| string| | +| *username {empty}* *| MongoDB Username| Username for accessing MongoDB.| string| | +|=== + +NOTE: Fields marked with ({empty}*) are mandatory. + +== Usage + +This section summarizes how the `mongodb-sink` can be used in various contexts. + +=== Knative Sink + +The `mongodb-sink` Kamelet can be used as Knative sink by binding it to a Knative object. + +.mongodb-sink-binding.yaml +[source,yaml] +---- +apiVersion: camel.apache.org/v1alpha1 +kind: KameletBinding +metadata: + name: mongodb-sink-binding +spec: + source: + ref: + kind: InMemoryChannel + apiVersion: messaging.knative.dev/v1 + name: mychannel + sink: + ref: + kind: Kamelet + apiVersion: camel.apache.org/v1alpha1 + name: mongodb-sink + properties: + collection: "The MongoDB Collection" + database: "The MongoDB Database" + hosts: "The MongoDB Hosts" + password: "The MongoDB Password" + username: "The MongoDB Username" + +---- + +Make sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to. + +Save the `mongodb-sink-binding.yaml` file into your hard drive, then configure it according to your needs. + +You can run the sink using the following command: + +[source,shell] +---- +kubectl apply -f mongodb-sink-binding.yaml +---- + +==== *Binding to Knative using the Kamel CLI:* + +The procedure described above can be simplified into a single execution of the `kamel bind` command: + +[source,shell] +---- +kamel bind channel/mychannel mongodb-sink -p "sink.collection=The MongoDB Collection" -p "sink.database=The MongoDB Database" -p "sink.hosts=The MongoDB Hosts" -p "sink.password=The MongoDB Password" -p "sink.username=The MongoDB Username" +---- + +This will create the KameletBinding under the hood and apply it to the current namespace in the cluster. + +=== Kafka Sink + +The `mongodb-sink` Kamelet can be used as Kafka sink by binding it to a Kafka topic. + +.mongodb-sink-binding.yaml +[source,yaml] +---- +apiVersion: camel.apache.org/v1alpha1 +kind: KameletBinding +metadata: + name: mongodb-sink-binding +spec: + source: + ref: + kind: KafkaTopic + apiVersion: kafka.strimzi.io/v1beta1 + name: my-topic + sink: + ref: + kind: Kamelet + apiVersion: camel.apache.org/v1alpha1 + name: mongodb-sink + properties: + collection: "The MongoDB Collection" + database: "The MongoDB Database" + hosts: "The MongoDB Hosts" + password: "The MongoDB Password" + username: "The MongoDB Username" + +---- + +Ensure that you've installed https://strimzi.io/[Strimzi] and created a topic named `my-topic` in the current namespace. +Make also sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to. + +Save the `mongodb-sink-binding.yaml` file into your hard drive, then configure it according to your needs. + +You can run the sink using the following command: + +[source,shell] +---- +kubectl apply -f mongodb-sink-binding.yaml +---- + +==== *Binding to Kafka using the Kamel CLI:* + +The procedure described above can be simplified into a single execution of the `kamel bind` command: + +[source,shell] +---- +kamel bind kafka.strimzi.io/v1beta1:KafkaTopic:my-topic mongodb-sink -p "sink.collection=The MongoDB Collection" -p "sink.database=The MongoDB Database" -p "sink.hosts=The MongoDB Hosts" -p "sink.password=The MongoDB Password" -p "sink.username=The MongoDB Username" +---- + +This will create the KameletBinding under the hood and apply it to the current namespace in the cluster. + +// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT diff --git a/library/camel-kamelets-catalog/src/main/resources/kamelets/mongodb-sink.kamelet.yaml b/library/camel-kamelets-catalog/src/main/resources/kamelets/mongodb-sink.kamelet.yaml new file mode 100644 index 000000000..a24f27cc2 --- /dev/null +++ b/library/camel-kamelets-catalog/src/main/resources/kamelets/mongodb-sink.kamelet.yaml @@ -0,0 +1,73 @@ +apiVersion: camel.apache.org/v1alpha1 +kind: Kamelet +metadata: + name: mongodb-sink + annotations: + camel.apache.org/kamelet.support.level: "Preview" + camel.apache.org/catalog.version: "main-SNAPSHOT" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L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IDExLjAxNiAxLjcwOCA1LjM2OCA0Ljc3NiA5Ljg2NiA4Ljc1IDEzLjc3YTM1LjA4IDM1LjA4IDAgMCAwIDMuMSAyLjY1Yy4zMTQgMCAuMzQ4LS4yOC40LS40ODhhOS41NyA5LjU3IDAgMCAwIC4zMTQtMS4zNmwuNy01LjIyOEwxNC4xNzQuMDY5eiIgZmlsbD0iIzZjYWM0OCIvPjxwYXRoIGQ9Ik0xNS44ODIgNTcuNjkxYy4wNy0uOC40NTQtMS40NjQuODcyLTIuMTI2LS40LS4xNzQtLjczMi0uNTItLjk3Ni0uOTA2YTYuNDcgNi40NyAwIDAgMS0uNTItMS4xNWMtLjQ4OC0xLjQ2NC0uNTkyLTMtLjczMi00LjQ5NnYtLjkwNmMtLjE3NC4xNC0uMjEgMS4zMjQtLjIxIDEuNS0uMTAyIDEuNTgxLS4zMTIgMy4xNTQtLjYyOCA0LjcwNi0uMTA0LjYyOC0uMTc0IDEuMjU0LS41NiAxLjgxMiAwIC4wNyAwIC4xNC4wMzQuMjQ0LjYyOCAxLjg0OC44IDMuNzMuOTA2IDUuNjQ4di43YzAgLjgzNi0uMDM0LjY2LjY2Ljk0LjI4LjEwNC41OTIuMTQuODcyLjM0OC4yMSAwIC4yNDQtLjE3NC4yNDQtLjMxNGwtLjEwNC0xLjE1di0zLjIwOGMtLjAzNC0uNTYuMDctMS4xMTYuMTQtMS42NHoiIGZpbGw9IiNjMmJmYmYiLz48L2c+PC9zeW1ib2w+PC9zdmc+" + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.group: "MongoDB" + labels: + camel.apache.org/kamelet.type: "sink" +spec: + definition: + title: "MongoDB Sink" + description: |- + Send documents to MongoDB. + + This Kamelet expects a JSON as body. + required: + - hosts + - collection + - password + - username + - database + type: object + properties: + hosts: + title: MongoDB Hosts + description: Comma separated list of MongoDB Host Addresses in host:port format. + type: string + collection: + title: MongoDB Collection + description: Sets the name of the MongoDB collection to bind to this endpoint. + type: string + password: + title: MongoDB Password + description: User password for accessing MongoDB. + type: string + format: password + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:password + username: + title: MongoDB Username + description: Username for accessing MongoDB. + type: string + database: + title: MongoDB Database + description: Sets the name of the MongoDB database to target. + type: string + types: + in: + mediaType: application/json + dependencies: + - "camel:kamelet" + - "camel:mongodb" + - "camel:jackson" + flow: + beans: + - name: local-mongodb + type: "#class:org.apache.camel.component.mongodb.MongoDbComponent" + from: + uri: kamelet:source + steps: + - to: + uri: "{{local-mongodb}}:test" + parameters: + hosts: "{{hosts}}" + collection: "{{collection}}" + password: "{{password}}" + username: "{{username}}" + database: "{{database}}" + operation: "insert" diff --git a/mongodb-sink.kamelet.yaml b/mongodb-sink.kamelet.yaml new file mode 100644 index 000000000..a24f27cc2 --- /dev/null +++ b/mongodb-sink.kamelet.yaml @@ -0,0 +1,73 @@ +apiVersion: camel.apache.org/v1alpha1 +kind: Kamelet +metadata: + name: mongodb-sink + annotations: + camel.apache.org/kamelet.support.level: "Preview" + camel.apache.org/catalog.version: "main-SNAPSHOT" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMzEgNjciIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlPSIjMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjx1c2UgeGxpbms6aHJlZj0iI0EiIHg9IjEiIHk9IjEiLz48c3ltYm9sIGlkPSJBIiBvdmVyZmxvdz0idmlzaWJsZSI+PGcgc3Ryb2tlPSJub25lIiBmaWxsLXJ1bGU9Im5vbnplcm8iPjxwYXRoIGQ9Ik0xNC4xNzQuMTc1bDEuNzA4IDMuMjA4Yy4zNzEuNTc5LjgwNC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jQ2NC0uNTkyLTMtLjczMi00LjQ5NnYtLjkwNmMtLjE3NC4xNC0uMjEgMS4zMjQtLjIxIDEuNS0uMTAyIDEuNTgxLS4zMTIgMy4xNTQtLjYyOCA0LjcwNi0uMTA0LjYyOC0uMTc0IDEuMjU0LS41NiAxLjgxMiAwIC4wNyAwIC4xNC4wMzQuMjQ0LjYyOCAxLjg0OC44IDMuNzMuOTA2IDUuNjQ4di43YzAgLjgzNi0uMDM0LjY2LjY2Ljk0LjI4LjEwNC41OTIuMTQuODcyLjM0OC4yMSAwIC4yNDQtLjE3NC4yNDQtLjMxNGwtLjEwNC0xLjE1di0zLjIwOGMtLjAzNC0uNTYuMDctMS4xMTYuMTQtMS42NHoiIGZpbGw9IiNjMmJmYmYiLz48L2c+PC9zeW1ib2w+PC9zdmc+" + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.group: "MongoDB" + labels: + camel.apache.org/kamelet.type: "sink" +spec: + definition: + title: "MongoDB Sink" + description: |- + Send documents to MongoDB. + + This Kamelet expects a JSON as body. + required: + - hosts + - collection + - password + - username + - database + type: object + properties: + hosts: + title: MongoDB Hosts + description: Comma separated list of MongoDB Host Addresses in host:port format. + type: string + collection: + title: MongoDB Collection + description: Sets the name of the MongoDB collection to bind to this endpoint. + type: string + password: + title: MongoDB Password + description: User password for accessing MongoDB. + type: string + format: password + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:password + username: + title: MongoDB Username + description: Username for accessing MongoDB. + type: string + database: + title: MongoDB Database + description: Sets the name of the MongoDB database to target. + type: string + types: + in: + mediaType: application/json + dependencies: + - "camel:kamelet" + - "camel:mongodb" + - "camel:jackson" + flow: + beans: + - name: local-mongodb + type: "#class:org.apache.camel.component.mongodb.MongoDbComponent" + from: + uri: kamelet:source + steps: + - to: + uri: "{{local-mongodb}}:test" + parameters: + hosts: "{{hosts}}" + collection: "{{collection}}" + password: "{{password}}" + username: "{{username}}" + database: "{{database}}" + operation: "insert"