This is a cache of https://docs.openshift.com/container-platform/4.3/serverless/knative_eventing/serverless-subscriptions.html. It is a snapshot of the page at 2024-11-28T02:22:17.394+0000.
Using subscriptions to send events from a channel to a sink - Knative Eventing | Serverless applications | OpenShift Container Platform 4.3
×

Subscriptions deliver events to event sinks from a Channel.

Creating a subscription

You can create a subscription to connect a service or other event sink to a channel.

Knative Eventing is a Technology Preview feature. The InMemoryChannel type is provided for development use only, and should not be used in a production environment.

Prerequisites
Procedure
  1. Create a Subscription object to connect a channel to a service, by creating a YAML file containing the following:

    apiVersion: messaging.knative.dev/v1beta1
    kind: Subscription
    metadata:
      name: my-subscription (1)
      namespace: default
    spec:
      channel: (2)
        apiVersion: messaging.knative.dev/v1beta1
        kind: Channel
        name: example-channel
      delivery: (3)
        deadLetterSink:
          ref:
            apiVersion: serving.knative.dev/v1
            kind: service
            name: error-handler
      subscriber: (4)
        ref:
          apiVersion: serving.knative.dev/v1
          kind: service
          name: event-display
    1 Name of the subscription.
    2 Configuration settings for the channel that the subscription connects to.
    3 Configuration settings for event delivery. This tells the subscription what happens to events that cannot be delivered to the subscriber. When this is configured, events that failed to be consumed are sent to the deadLetterSink. The event is dropped, no re-delivery of the event is attempted, and an error is logged in the system. The deadLetterSink value must be a Destination.
    4 Configuration settings for the subscriber. This is the event sink that events are delivered to from the channel.
  2. Apply the YAML file by entering:

    $ oc apply -f <filename>