About sinks
Addressable objects receive and acknowledge an event delivered over HTTP to an address defined in their field. As a special case, the core Kubernetes Service object also fulfils the Addressable interface.
Callable objects are able to receive an event delivered over HTTP and transform the event, returning 0 or 1 new events in the HTTP response. These returned events may be further processed in the same way that events from an external event source are processed.
Sink is used as a reference to an object that resolves to a URI to use as the sink.
A sink
definition supports the following fields:
Note
At least one of ref
or uri
is required. If both are specified, is resolved into the URL from the Addressable ref
result.
Contract
This results in the K_SINK
environment variable being set on the subject
as "http://mysink.default.svc.cluster.local/extra/path"
.
To use a Kubernetes custom resource (CR) as a sink for events, you must:
Make the CR Addressable. You must ensure that the CR contains a
status.address.url
. For more information, see the spec for Addressable resources.Create an Addressable-resolver ClusterRole to obtain the necessary RBAC rules for the sink to receive events.
For example, you can create a
kafkasinks-addressable-resolver
ClusterRole to allowget
, , andwatch
access to KafkaSink objects and statuses:
For example:
Where;
<kafka-sink-name>
is the name of a KafkaSink object.
When you create an event-producing CR by using the Knative (kn
) CLI, you can specify a sink where events are sent to from that resource, by using the --sink
flag.
The following example creates a SinkBinding that uses a Service, http://event-display.svc.cluster.local
, as the sink:
The svc
in http://event-display.svc.cluster.local
determines that the sink is a Knative Service. Other default sink prefixes include Channel and Broker.
Tip
Name | Maintainer | Description |
---|---|---|
KafkaSink | Knative | Send events to a Kafka topic |
Knative | Send events to a Redis Stream |