1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-07 09:46:53 +01:00
Files
openshift-docs/modules/serverless-creating-subscriptions-yaml.adoc
2020-10-08 18:38:09 +00:00

54 lines
1.8 KiB
Plaintext

// Module included in the following assemblies:
//
// <List assemblies here, each on a new line>
// * serverless/event_workflows/serverless-channels.adoc
[id="serverless-creating-subscriptions-yaml_{context}"]
= Connecting a channel to a sink using subscriptions with YAML
You can create a `Subscription` object to connect a channel to a sink. In the following procedure, the example sink is a Knative service named `error-handler`.
.Procedure
. Create a YAML file and copy the following sample code into it:
+
[source,yaml]
----
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 link:https://pkg.go.dev/knative.dev/pkg/apis/duck/v1?tab=doc#Destination[Destination].
<4> Configuration settings for the subscriber. This is the event sink that events are delivered to from the channel.
. Apply the YAML file:
+
[source,terminal]
----
$ oc apply -f <filename>
----