|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// <List assemblies here, each on a new line> |
| 4 | +// * serverless/knative_eventing/serverless-subscriptions.adoc |
| 5 | + |
| 6 | +[id="serverless-creating-subscriptions_{context}"] |
| 7 | += Creating a subscription |
| 8 | + |
| 9 | +You can create a subscription to connect a service or other event sink to a channel. |
| 10 | + |
| 11 | +[IMPORTANT] |
| 12 | +==== |
| 13 | +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. |
| 14 | +==== |
| 15 | + |
| 16 | +.Prerequisites |
| 17 | + |
| 18 | +* You must have a current installation of xref:../../serverless/installing_serverless/installing-openshift-serverless.adoc#serverless-install-web-console_installing-openshift-serverless[{ServerlessProductName}], including Knative Serving and Eventing, in your {product-title} cluster. This can be installed by a cluster administrator. |
| 19 | +* If you do not have an existing sink that you wish to use, create a Service to use as a sink by following the documentation on xref:../../serverless/serving-creating-managing-apps.adoc#serving-creating-managing-apps[Creating and managing serverless applications]. |
| 20 | +* You must have a channel to connect your subscription to. See xref:../../serverless/knative_eventing/serverless-channels.adoc#serverless-channels[Using channels with Knative Eventing]. |
| 21 | + |
| 22 | +.Procedure |
| 23 | + |
| 24 | +. Create a Subscription object to connect a channel to a service, by creating a YAML file containing the following: |
| 25 | ++ |
| 26 | +[source,yml] |
| 27 | +---- |
| 28 | +apiVersion: messaging.knative.dev/v1beta1 |
| 29 | +kind: Subscription |
| 30 | +metadata: |
| 31 | + name: my-subscription <1> |
| 32 | + namespace: default |
| 33 | +spec: |
| 34 | + channel: <2> |
| 35 | + apiVersion: messaging.knative.dev/v1beta1 |
| 36 | + kind: Channel |
| 37 | + name: example-channel |
| 38 | + delivery: <3> |
| 39 | + deadLetterSink: |
| 40 | + ref: |
| 41 | + apiVersion: serving.knative.dev/v1 |
| 42 | + kind: Service |
| 43 | + name: error-handler |
| 44 | + subscriber: <4> |
| 45 | + ref: |
| 46 | + apiVersion: serving.knative.dev/v1 |
| 47 | + kind: Service |
| 48 | + name: event-display |
| 49 | +---- |
| 50 | ++ |
| 51 | +<1> Name of the subscription. |
| 52 | +<2> Configuration settings for the channel that the subscription connects to. |
| 53 | +<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]. |
| 54 | +<4> Configuration settings for the subscriber. This is the event sink that events are delivered to from the channel. |
| 55 | + |
| 56 | +. Apply the YAML file by entering: |
| 57 | ++ |
| 58 | +---- |
| 59 | +$ oc apply -f <FILENAME> |
| 60 | +---- |
0 commit comments