Trigger a workload with an event

We already know how to create and expose a workload (Function and microservice). Now it's time to actually use an event to trigger a workload.

Create a Function

First, create a sample Function that prints out the received event to console:

  • Kyma Dashboard
  • kubectl

Create a Subscription

Next, to subscribe to events, we need a Subscription custom resource. We're going to subscribe to events of the type order.received.v1. All the published events of this type are then forwarded to an HTTP endpoint called Sink. You can define this endpoint in the Subscription's spec.

  • Kyma Dashboard
  • kubectl

Trigger the workload with an event

We created the lastorder Function and subscribed to the order.received.v1 event by creating a Subscription CR. Now it's time to publish your event and trigger the Function. In this example, we'll port-forward the Kyma Eventing Service to localhost.

  1. Port-forward the Kyma Eventing Service to localhost. We will use port 3000. In your terminal, run:
    Click to copy
    kubectl -n kyma-system port-forward service/eventing-event-publisher-proxy 3000:80
  2. Now publish an event to trigger your Function. In another terminal window, run:
  • curl
  • CloudEvents Conformance Tool

Verify the event delivery

To verify that the event was properly delivered, check the logs of the Function:

  • Kyma Dashboard
  • kubectl