In-cluster Eventing allows publishers to send messages and subscribers to receive them without the need for a Kyma Application. This means that instead of the usual event flow where Application Connector publishes events to the Event Publisher Proxy, events can be published from within the cluster directly to the Event Publisher Proxy.
in-cluster-events
kubectl create ns in-cluster-events
in-cluster-events
namespace.module.exports = {
main: function (event, context) {
console.log(event.data);
}
}
cat <<EOF | kubectl -n in-cluster-events apply -f -
apiVersion: eventing.kyma-project.io/v1alpha1
kind: Subscription
metadata:
name: mysub
spec:
filter:
filters:
- eventSource:
property: source
type: exact
value: ""
eventType:
property: type
type: exact
value: sap.kyma.custom.nonexistingapp.order.created.v1
protocol: ""
protocolsettings: {}
sink: http://event-subscriber.in-cluster-events.svc.cluster.local #this is the service name and port
EOF
Now we need a workload running inside Kyma runtime that can publish events. It can be a microservice or function. The events in Kyma conform to cloudevents specification. You can use various cloudevents SDKs available to produce and consume the events in your preferred technology. To keep this tutorial simple, I will be using curl as my event producer.
Let's go ahead and launch a pod that has the curl command available and enter the shell.
kubectl -n in-cluster-events run curl --image=radial/busyboxplus:curl -i --tty
curl -k -i -X POST \
"http://eventing-event-publisher-proxy.kyma-system/publish" \
-H "Content-Type: application/cloudevents+json" \
--data @- << EOF
{
"source": "kyma",
"specversion": "1.0",
"eventtypeversion": "v1",
"data": {"orderCode":"3211213"},
"datacontenttype": "application/json",
"id": "759815c3-b142-48f2-bf18-c6502dc0998f",
"type": "sap.kyma.custom.nonexistingapp.order.created.v1"
}
EOF
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
7 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |