Skip to content

Introducing the CloudEvents Player

In this tutorial, you will be using the CloudEvents Player to showcase the core concepts of Knative Eventing. By the end of this tutorial, you should have something that looks like this:

Figure 6.6 from Knative in Action
Here, the CloudEvents Player is acting as both a Source and a Sink for CloudEvents.

Creating your first Source

The CloudEvents Player acts as a Source for CloudEvents by intaking the URL of our Broker as an environment variable (BROKER_URL) and sending CloudEvents via the UI.

Create the CloudEvents Player Service:

kn service create cloudevents-player \
--image ruromero/cloudevents-player:latest \
--env BROKER_URL=http://broker-ingress.knative-eventing.svc.cluster.local/default/default
//TODO

Expected Output

Service 'cloudevents-player' created to latest revision 'cloudevents-player-vwybw-1' is available at URL:
http://cloudevents-player.default.127.0.0.1.nip.io

Wait, my Revision is named something different!

Since we didn't assign a revision-name, Knative Serving automatically created one for us, it's ok if your Revision is named something different.

Examining the CloudEvents Player

We can use the CloudEvents Player to send and receive CloudEvents. If you open the Service URL in your browser, you should be greeted by a form titled "Create event."

The user interface for the CloudEvents Player
What do these fields mean?
Field Description
Event ID A unique ID. Click the loop icon to generate a new one.
Event Type An event type.
Event Source An event source.
Specversion Demarcates which CloudEvents spec you're using (should always be 1.0).
Message The data section of the CloudEvent, a payload which is carrying the data you care to be delivered.

For more information on the CloudEvents Specification, check out the CloudEvents Spec.

Fill out the form with whatever you data you would like to and hit the "SEND EVENT" button.

Make sure your Event Source does not contain any spaces!

Tip: Clicking the will show you the CloudEvent as the Broker sees it.

The icon in the "Status" column implies that the event has been sent to our Broker, but where has the event gone? Well, right now, nowhere!

A Broker is simply a receptacle for events. In order for your events to be sent somewhere, you must create a Trigger which listens for your events and places them somewhere. Let's do that next!