It is possible to sink events from an event source to a Knative Eventing channel. Channels are Custom Resources (CRs) that define a single event-forwarding and persistence layer. After events have been sent to a channel, these events can be sent to multiple Knative services by using a subscription.

The default configuration for channel instances is defined in the default-ch-webhook ConfigMap. However, developers can still create their own channels directly by instantiating a supported channel object.

Supported channel types

Currently, OpenShift Serverless only supports the use of InMemoryChannel channels as part of the Knative Eventing Technology Preview.

The following are limitations of InMemoryChannel channels:

  • No event persistence is available. If a Pod goes down, events on that Pod will be lost.

  • InMemoryChannel channels do not implement event ordering, so two events that are received in the channel at the same time may be delivered to a subscriber in any order.

  • If a subscriber rejects an event, there are no redelivery attempts. Instead, the rejected event is sent to a dead letter sink if this sink exists, or is otherwise dropped.

Creating a channel with cluster default configuration

To create a channel using the cluster default configuration set by the cluster administrator, you must create a generic Channel custom object.

Example Channel object
apiVersion: messaging.knative.dev/v1beta1
kind: Channel
metadata:
  name: example-channel
  namespace: default

When the above Channel object is created, a mutating admission webhook adds a set of spec.channelTemplate properties for the Channel object based on the default channel implementation chosen by the cluster administrator.

Example Channel object with spec.channelTemplate properties
apiVersion: messaging.knative.dev/v1beta1
kind: Channel
metadata:
  name: example-channel
  namespace: default
spec:
  channelTemplate:
    apiVersion: messaging.knative.dev/v1beta1
    kind: InMemoryChannel

The channel controller will then create the backing channel instance based on that spec.channelTemplate configuration. The spec.channelTemplate properties cannot be changed after creation, because they are set by the default channel mechanism rather than by the user.

When this mechanism is used, two objects are created, a generic channel, and an InMemoryChannel channel.

The generic channel acts as a proxy that copies its subscriptions to the InMemoryChannel, and sets its status to reflect the status of the backing InMemoryChannel channel.

Because the channel in this example is created in the default namespace, the channel uses the cluster default, which is InMemoryChannel.