From ddc42e7470ca35665b1abb156484255208ab1db0 Mon Sep 17 00:00:00 2001 From: Maria Arias de Reyna Date: Mon, 26 Apr 2021 14:34:37 +0200 Subject: [PATCH 1/3] Adding INSERT/INDEX ElasticSearch Kamelet --- .../kamelets/elasticsearch-index-sink.svg | 25 ++++++ .../ROOT/pages/elasticsearch-index-sink.adoc | 67 ++++++++++++++++ elasticsearch-index-sink.kamelet.yaml | 76 +++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 docs/modules/ROOT/assets/images/kamelets/elasticsearch-index-sink.svg create mode 100644 docs/modules/ROOT/pages/elasticsearch-index-sink.adoc create mode 100755 elasticsearch-index-sink.kamelet.yaml diff --git a/docs/modules/ROOT/assets/images/kamelets/elasticsearch-index-sink.svg b/docs/modules/ROOT/assets/images/kamelets/elasticsearch-index-sink.svg new file mode 100644 index 000000000..af0264a21 --- /dev/null +++ b/docs/modules/ROOT/assets/images/kamelets/elasticsearch-index-sink.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/modules/ROOT/pages/elasticsearch-index-sink.adoc b/docs/modules/ROOT/pages/elasticsearch-index-sink.adoc new file mode 100644 index 000000000..b6ed91b42 --- /dev/null +++ b/docs/modules/ROOT/pages/elasticsearch-index-sink.adoc @@ -0,0 +1,67 @@ +// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT += image:kamelets/elasticsearch-index-sink.svg[] ElasticSearch Index Sink + +*Provided by: "Apache Software Foundation"* + +Insert data into ElasticSearch. Input data must have JSON format. + +== Configuration Options + +The following table summarizes the configuration options available for the `elasticsearch-index-sink` Kamelet: +[width="100%",cols="2,^2,3,^2,^2,^3",options="header"] +|=== +| Property| Name| Description| Type| Default| Example +| *clusterName {empty}* *| ElasticSearch cluster name| Name of the cluster.| string| | +| *hostAddresses {empty}* *| Host addresses| Comma separated list with ip:port formatted remote transport addresses to use.| string| | +| *indexName {empty}* *| Index in ElasticSearch| The name of the index to act against.| string| | +| enableSSL| Enable SSL| Do we want to connect using SSL?| boolean| `true`| +| password| Password| Password to connect to ElasticSearch.| string| | +| user| Username| Username to connect to ElasticSearch.| string| | +|=== + +NOTE: Fields marked with ({empty}*) are mandatory. + +== Usage + +This section summarizes how the `elasticsearch-index-sink` can be used in various contexts. + +=== Knative Sink + +The `elasticsearch-index-sink` Kamelet can be used as Knative sink by binding it to a Knative object. + +.elasticsearch-index-sink-binding.yaml +[source,yaml] +---- +apiVersion: camel.apache.org/v1alpha1 +kind: KameletBinding +metadata: + name: elasticsearch-index-sink-binding +spec: + source: + ref: + kind: InMemoryChannel + apiVersion: messaging.knative.dev/v1 + name: mychannel + sink: + ref: + kind: Kamelet + apiVersion: camel.apache.org/v1alpha1 + name: elasticsearch-index-sink + properties: + clusterName: "The ElasticSearch cluster name" + hostAddresses: "The Host addresses" + indexName: "The Index in ElasticSearch" + +---- + +Make sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to. + +Save the `elasticsearch-index-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 elasticsearch-index-sink-binding.yaml +---- +// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT diff --git a/elasticsearch-index-sink.kamelet.yaml b/elasticsearch-index-sink.kamelet.yaml new file mode 100755 index 000000000..2307971bb --- /dev/null +++ b/elasticsearch-index-sink.kamelet.yaml @@ -0,0 +1,76 @@ +apiVersion: camel.apache.org/v1alpha1 +kind: Kamelet +metadata: + name: elasticsearch-index-sink + labels: + camel.apache.org/kamelet.type: "sink" + annotations: + camel.apache.org/kamelet.group: "ElasticSearch" + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1NTAgMjUwIiB2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cgNS4xaDI2YzUuNyAwIDEwLjktMi40IDE0LjYtNi4yLTcuMi0xMC43LTE5LjQtMTcuOC0zMy4zLTE3Ljh6IiBmaWxsPSIjZmVkMTBhIi8+Cjwvc3ZnPg==" +spec: + sources: + - content: |- + public class ESWorkaround extends org.apache.camel.builder.RouteBuilder { + @Override + public void configure() throws Exception { + getContext().setAutowiredEnabled(false); + } + } + name: ESWorkaround.java + definition: + title: "ElasticSearch Index Sink" + description: |- + Insert data into ElasticSearch. Input data must have JSON format. + required: + - query + - clusterName + - indexName + - hostAddresses + properties: + user: + title: Username + description: Username to connect to ElasticSearch. + type: string + password: + title: Password + description: Password to connect to ElasticSearch. + type: string + enableSSL: + title: Enable SSL + description: Do we want to connect using SSL? + type: boolean + default: true + hostAddresses: + title: Host addresses + description: Comma separated list with ip:port formatted remote transport addresses to use. + type: string + indexName: + title: Index in ElasticSearch + description: The name of the index to act against. + type: string + clusterName: + title: ElasticSearch cluster name + description: Name of the cluster. + type: string + dependencies: + - "camel:elasticsearch-rest" + - "camel:gson" + types: + out: + mediaType: application/json + flow: + from: + uri: kamelet:source + steps: + - to: + uri: "kamelet-reify:elasticsearch-rest:{{clusterName}}" + parameters: + operation: "INDEX" + indexName: "{{indexName}}" + hostAddresses: "{{hostAddresses}}" + enableSSL: "{{enableSSL}}" + user: "{{user}}" + password: "{{password}}" + - marshal: + json: {} From f2fbc8230748494e92eefecf38f7fdcd8d32cb8d Mon Sep 17 00:00:00 2001 From: Maria Arias de Reyna Date: Thu, 29 Apr 2021 11:03:31 +0200 Subject: [PATCH 2/3] Adding JSON as input media type --- elasticsearch-index-sink.kamelet.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/elasticsearch-index-sink.kamelet.yaml b/elasticsearch-index-sink.kamelet.yaml index 2307971bb..006f1e00c 100755 --- a/elasticsearch-index-sink.kamelet.yaml +++ b/elasticsearch-index-sink.kamelet.yaml @@ -59,6 +59,8 @@ spec: types: out: mediaType: application/json + in: + mediaType: application/json flow: from: uri: kamelet:source From eae9c8af42c4d704c2ba24790db2556507f1c3f4 Mon Sep 17 00:00:00 2001 From: Maria Arias de Reyna Date: Thu, 29 Apr 2021 11:06:54 +0200 Subject: [PATCH 3/3] Fixing validations --- elasticsearch-index-sink.kamelet.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/elasticsearch-index-sink.kamelet.yaml b/elasticsearch-index-sink.kamelet.yaml index 006f1e00c..e59c22070 100755 --- a/elasticsearch-index-sink.kamelet.yaml +++ b/elasticsearch-index-sink.kamelet.yaml @@ -23,7 +23,6 @@ spec: description: |- Insert data into ElasticSearch. Input data must have JSON format. required: - - query - clusterName - indexName - hostAddresses @@ -42,7 +41,7 @@ spec: type: boolean default: true hostAddresses: - title: Host addresses + title: Host Addresses description: Comma separated list with ip:port formatted remote transport addresses to use. type: string indexName: @@ -50,7 +49,7 @@ spec: description: The name of the index to act against. type: string clusterName: - title: ElasticSearch cluster name + title: ElasticSearch Cluster Name description: Name of the cluster. type: string dependencies: