mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-06 06:46:26 +01:00
57 lines
2.3 KiB
Plaintext
57 lines
2.3 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * /serverless/develop/serverless-subs.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="serverless-creating-subscriptions-yaml_{context}"]
|
|
= Creating a subscription by using YAML
|
|
|
|
After you have created a channel and an event sink, you can create a subscription to enable event delivery. Creating Knative resources by using YAML files uses a declarative API, which enables you to describe subscriptions declaratively and in a reproducible manner. To create a subscription by using YAML, you must create a YAML file that defines a `Subscription` object, then apply it by using the `oc apply` command.
|
|
|
|
.Prerequisites
|
|
|
|
* The {ServerlessOperatorName} and Knative Eventing are installed on the cluster.
|
|
* Install the OpenShift CLI (`oc`).
|
|
* You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in {product-title}.
|
|
|
|
.Procedure
|
|
|
|
* Create a `Subscription` object:
|
|
** 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>
|
|
----
|