Use Multiple Sources in One EventSource
Use Multiple Sources in One EventSource
This document describes how to use multiple sources in one EventSource.
Prerequisites
- You need to create a function as the target function to be triggered. Please refer to Create a function for more details.
- You need to create a Kafka cluster. Please refer to Create a Kafka cluster for more details.
Use Multiple Sources in One EventSource
- Use the following content to create an EventSource configuration file (for example,
eventsource-multi.yaml).
Note
* The following example defines an event source named `my-eventsource` and mark the events generated by the specified Kafka server as `sample-three`.
* `spec.sink` references the target function (Knative service).
* The configuration of `spec.cron` is to trigger the function defined in `spec.sink` every 5 seconds.
apiVersion: events.openfunction.io/v1alpha1
kind: EventSource
metadata:
name: my-eventsource
spec:
logLevel: "2"
kafka:
sample-three:
brokers: "kafka-server-kafka-brokers.default.svc.cluster.local:9092"
topic: "events-sample"
authRequired: false
cron:
sample-three:
schedule: "@every 5s"
sink:
uri: "http://openfunction.io.svc.cluster.local/default/sink"
- Run the following command to apply the configuration file.
kubectl apply -f eventsource-multi.yaml
- Run the following commands to observe changes.
$ kubectl get eventsources.events.openfunction.io
NAME EVENTBUS SINK STATUS
my-eventsource Ready
$ kubectl get components
NAME AGE
serving-vqfk5-component-esc-cron-sample-three-dzcpv 35s
serving-vqfk5-component-esc-kafka-sample-one-nr9pq 35s
serving-vqfk5-component-ts-my-eventsource-default-q6g6m 35s
$ kubectl get deployments.apps
NAME READY UP-TO-DATE AVAILABLE AGE
serving-4x5wh-ksvc-wxbf2-v100-deployment 1/1 1 1 3h14m
serving-vqfk5-deployment-v100-vdmvj 1/1 1 1 48s
