You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Timothy Dilbert <ti...@bmt.ky.INVALID> on 2023/03/15 02:48:15 UTC

Utilising Apache Camel Webhook KameletBinding

Hello,

I am trying to create a proof-of-concept KameletBinding using a webhook
source that logs the request, defined using the following YAML DSL:

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: webhook-test
namespace: ky9999-email-filer
spec:
source:
ref:
apiVersion: camel.apache.org/v1alpha1
name: webhook-source
kind: Kamelet
properties:
subpath: Helloworld
sink:
ref:
apiVersion: camel.apache.org/v1alpha1
name: log-sink
kind: Kamelet
properties:
showHeaders: 'true'
showBody: 'true'


How do I invoke this webhook now? The webhook documentation says to use
https://integration-external-url/HelloWorld. How do I get the
*integration-external-url*?

I'm a noob so I apologise for the silly question. Any help would be much
appreciated.

Timothy D.

Re: Utilising Apache Camel Webhook KameletBinding

Posted by Pasquale Congiusti <pa...@gmail.com>.
Hello,
I think the best place to understand how to use it is the Kamelet catalog
documentation or directly the Kamelet source code definition [1]. You can
see that the Kamelet source uses a platform-http component, so, it would be
advisable to have a look to see how to fine tune it accordingly. If you use
Camel K, you can run this (the bind command is equivalent to a creation of
a KameletBinding):

$ kamel bind webhook-source log-sink -t service.type=NodePort

The service type is good if you're using a local cluster such as Minikube.
Check any other way to expose your service according the cluster
configuration. In Minikube you can get the local service url via:

$ minikube service webhook-source-to-log-sink --url=false
|-----------|----------------------------|-------------|---------------------------|
| NAMESPACE |            NAME            | TARGET PORT |            URL
       |
|-----------|----------------------------|-------------|---------------------------|
| default   | webhook-source-to-log-sink | http/80     |
http://192.168.49.2:32056 |
|-----------|----------------------------|-------------|---------------------------|

And at this stage it would be easy to call the service with (webhook path
is the default if none is provided):

$ curl -ikv http://192.168.49.2:32056/webhook

Of course, since there is no intermediate step in the Binding, the output
in the log will be empty:

[2] 2023-03-16 09:43:49,599 INFO  [io.quarkus] (main) camel-k-integration
1.12.0 on JVM (powered by Quarkus 2.16.0.Final) started in 2.060s.
Listening on: http://0.0.0.0:8080
[2] 2023-03-16 09:43:49,600 INFO  [io.quarkus] (main) Profile prod
activated.
[2] 2023-03-16 09:43:49,600 INFO  [io.quarkus] (main) Installed features:
[camel-attachments, camel-bean, camel-core, camel-k-core, camel-k-runtime,
camel-kamelet, camel-kubernetes, camel-log, camel-platform-http,
camel-yaml-dsl, cdi, kubernetes-client, security,
smallrye-context-propagation, vertx]
[2] 2023-03-16 09:44:06,915 INFO  [log-sink] (executor-thread-0)
Exchange[ExchangePattern: InOut, BodyType: null, Body: [Body is null]]
[2] 2023-03-16 09:44:12,227 INFO  [log-sink] (executor-thread-0)
Exchange[ExchangePattern: InOut, BodyType: null, Body: [Body is null]]

Hope this helps,
Pasquale.

[1]
https://github.com/apache/camel-kamelets/blob/main/kamelets/webhook-source.kamelet.yaml

On Wed, Mar 15, 2023 at 3:48 AM Timothy Dilbert
<ti...@bmt.ky.invalid> wrote:

> Hello,
>
> I am trying to create a proof-of-concept KameletBinding using a webhook
> source that logs the request, defined using the following YAML DSL:
>
> apiVersion: camel.apache.org/v1alpha1
> kind: KameletBinding
> metadata:
> name: webhook-test
> namespace: ky9999-email-filer
> spec:
> source:
> ref:
> apiVersion: camel.apache.org/v1alpha1
> name: webhook-source
> kind: Kamelet
> properties:
> subpath: Helloworld
> sink:
> ref:
> apiVersion: camel.apache.org/v1alpha1
> name: log-sink
> kind: Kamelet
> properties:
> showHeaders: 'true'
> showBody: 'true'
>
>
> How do I invoke this webhook now? The webhook documentation says to use
> https://integration-external-url/HelloWorld. How do I get the
> *integration-external-url*?
>
> I'm a noob so I apologise for the silly question. Any help would be much
> appreciated.
>
> Timothy D.
>