Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit bc1d9b7

Browse files
committed
dls fixes
1 parent 479ce00 commit bc1d9b7

File tree

2 files changed

+269
-64
lines changed

2 files changed

+269
-64
lines changed

delme.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
apiVersion: eventing.knative.dev/v1
2+
kind: Broker
3+
metadata:
4+
name: events
5+
spec:
6+
delivery:
7+
deadLetterSink:
8+
ref:
9+
apiVersion: serving.knative.dev/v1
10+
kind: Service
11+
name: sockeye
12+
backoffDelay: "PT0.5S" # or ISO8601 duration
13+
backoffPolicy: exponential # or linear
14+
retry: 2
15+
---
16+
apiVersion: sources.knative.dev/v1
17+
kind: PingSource
18+
metadata:
19+
name: ping-sockeye
20+
spec:
21+
data: '{"name": "triggermesh"}'
22+
schedule: "*/1 * * * *"
23+
sink:
24+
ref:
25+
apiVersion: eventing.knative.dev/v1
26+
kind: Broker
27+
name: events
28+
---
29+
apiVersion: serving.knative.dev/v1
30+
kind: Service
31+
metadata:
32+
name: sockeye
33+
spec:
34+
template:
35+
spec:
36+
containers:
37+
- image: docker.io/n3wscott/sockeye:v0.7.0@sha256:e603d8494eeacce966e57f8f508e4c4f6bebc71d095e3f5a0a1abaf42c5f0e48
38+
---
39+
40+
apiVersion: eventing.knative.dev/v1
41+
kind: Trigger
42+
metadata:
43+
name: failtest
44+
spec:
45+
broker: events
46+
subscriber:
47+
ref:
48+
apiVersion: serving.knative.dev/v1
49+
kind: Service
50+
name: event-display
51+
52+
53+
---
54+
55+
apiVersion: serving.knative.dev/v1
56+
kind: Service
57+
metadata:
58+
name: event-display
59+
spec:
60+
template:
61+
spec:
62+
containers:
63+
- image: docker.io/n3wscott/sockeye:v0.7.0@sha256:e603d8494eeacce966e57f8f508e4c4f6bebc71d095e3f5a0a1abaf42c5f0e48
64+
name: user-container

docs/guides/creatingadls.md

Lines changed: 205 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,75 +2,131 @@
22

33
## What is a Dead Letter Sink?
44

5-
TriggerMesh provides various configuration parameters to control the delivery of events in case of failure. For instance, you can decide to retry sending events that failed to be consumed, and if this didn't work you can decide to forward those events to a dead letter sink.
5+
A [Dead Letter Sink](https://knative.dev/docs/eventing/event-delivery/) is a Knative construct that allows the user to configure a destination for events that would otherwise be dropped due to some delivery failure. This is useful for scenarios where you want to ensure that events are not lost due to a failure in the underlying system.
66

7-
## Implementing a Dead Letter Sink
87

9-
There are two ways to implement a dead letter sink, either by use of a Subscription or by use of a Broker.
8+
## Creating a Bridge with a Dead Letter Sink.
109

11-
### Subscription Configuration
10+
In this example we are going to create a [Bridge](https://docs.triggermesh.io/concepts/) that contains a [PingSource](https://knative.dev/docs/eventing/sources/ping-source/) object that will emit an event on a regular basis to a [Broker](https://knative.dev/docs/eventing/broker/), named `events`, that will then forward the event to a [Service](https://github.com/knative/specs/blob/main/specs/serving/knative-api-specification-1.0.md#service), named `event-display`. We will also be configuring our [Broker](https://knative.dev/docs/eventing/broker/) to use a [Dead Letter Sink](https://knative.dev/docs/eventing/event-delivery/) so that in the case of a delivery error to `event-display` the event will go to another [Service](https://github.com/knative/specs/blob/main/specs/serving/knative-api-specification-1.0.md#service) named `event-failure-capture`, instead of being lost into the void. We will then break the bridge by removing the `event-display` service, so that we can view the [Dead Letter Sink](https://knative.dev/docs/eventing/event-delivery/) in action!
1211

13-
You can configure how events are delivered for each Subscription by adding a delivery spec to the Subscription object, as shown in the following example:
12+
13+
### Step 1: Create the Broker
14+
15+
Create a new [Broker](https://knative.dev/docs/eventing/broker/) with following configuration:
1416

1517
```yaml
16-
apiVersion: messaging.knative.dev/v1
17-
kind: Subscription
18+
apiVersion: eventing.knative.dev/v1
19+
kind: Broker
1820
metadata:
19-
name: example-subscription
20-
namespace: example-namespace
21+
name: events
2122
spec:
2223
delivery:
2324
deadLetterSink:
2425
ref:
25-
apiVersion: serving.knative.dev/v1
26-
kind: Service
27-
name: example-sink
28-
backoffDelay: <duration>
29-
backoffPolicy: <policy-type>
30-
retry: <integer>
26+
apiVersion: serving.knative.dev/v1
27+
kind: Service
28+
name: event-failure-capture
29+
backoffDelay: "PT0.5S" # or ISO8601 duration
30+
backoffPolicy: exponential # or linear
31+
retry: 2
3132
```
3233
33-
Where:
34+
Here a [Broker](https://knative.dev/docs/eventing/broker/) named `events` with a [Dead Letter Sink](https://knative.dev/docs/eventing/event-delivery/) configured to send the events to a [Service](https://github.com/knative/specs/blob/main/specs/serving/knative-api-specification-1.0.md#service) `sockeye` is configured with a `backoffDelay` of `0.5s`, a `backoffPolicy` of `exponential`, and a `retry` number of 2 (more info about those properties can be found [here](https://knative.dev/docs/eventing/event-delivery/#configuring-subscription-event-delivery).
3435

35-
The `deadLetterSink` spec contains configuration settings to enable using a dead letter sink. This tells the Subscription what happens to events that cannot be delivered to the subscriber. When this is configured, events that fail to be delivered are sent to the dead letter sink destination. The destination can be a Knative Service or a URI. In the example, the destination is a Service object, or Knative Service, named example-sink.
3636

37-
The `backoffDelay` delivery parameter specifies the time delay before an event delivery retry is attempted after a failure. The duration of the backoffDelay parameter is specified using the ISO 8601 format. For example, PT1S specifies a 1 second delay.
3837

39-
The `backoffPolicy` delivery parameter can be used to specify the retry back off policy. The policy can be specified as either linear or exponential. When using the linear back off policy, the back off delay is the time interval specified between retries. When using the exponential back off policy, the back off delay is equal to backoffDelay*2^<numberOfRetries>.
40-
retry specifies the number of times that event delivery is retried before the event is sent to the dead letter sink.
38+
### Step 2: Create the PingSource
4139

42-
43-
### Broker Configuration
40+
Create a [PingSource](https://knative.dev/docs/eventing/sources/ping-source/) object with the following configuration:
4441

45-
You can configure how events are delivered for each Broker by adding a delivery spec, as shown in the following example:
42+
```yaml
43+
apiVersion: sources.knative.dev/v1
44+
kind: PingSource
45+
metadata:
46+
name: ping-sockeye
47+
spec:
48+
data: '{"name": "triggermesh"}'
49+
schedule: "*/1 * * * *"
50+
sink:
51+
ref:
52+
apiVersion: eventing.knative.dev/v1
53+
kind: Broker
54+
name: events
55+
```
56+
57+
### Step 3: Create the `event-display` Service
58+
59+
Create a [Service](https://github.com/knative/specs/blob/main/specs/serving/knative-api-specification-1.0.md#service) named `event-display` with the following configuration:
60+
61+
```yaml
62+
apiVersion: serving.knative.dev/v1
63+
kind: Service
64+
metadata:
65+
name: event-display
66+
spec:
67+
template:
68+
spec:
69+
containers:
70+
- image: docker.io/n3wscott/sockeye:v0.7.0@sha256:e603d8494eeacce966e57f8f508e4c4f6bebc71d095e3f5a0a1abaf42c5f0e48
71+
name: user-container
72+
```
73+
74+
### Step 4: Create the `event-display` Trigger
75+
76+
Create a [Trigger](https://knative.dev/docs/eventing/broker/triggers/) to route events to the `event-display` [Service](https://github.com/knative/specs/blob/main/specs/serving/knative-api-specification-1.0.md#service) with the following configuration:
4677

4778
```yaml
4879
apiVersion: eventing.knative.dev/v1
49-
kind: Broker
80+
kind: Trigger
5081
metadata:
51-
name: with-dead-letter-sink
82+
name: failtest
5283
spec:
53-
delivery:
54-
deadLetterSink:
55-
ref:
56-
apiVersion: serving.knative.dev/v1
57-
kind: Service
58-
name: example-sink
59-
backoffDelay: <duration>
60-
backoffPolicy: <policy-type>
61-
retry: <integer>
84+
broker: events
85+
subscriber:
86+
ref:
87+
apiVersion: serving.knative.dev/v1
88+
kind: Service
89+
name: event-display
90+
```
91+
92+
### Step 5: Create the `event-failure-capture` Service
93+
94+
Create a [Service](https://github.com/knative/specs/blob/main/specs/serving/knative-api-specification-1.0.md#service) named `event-failure-capture` with the following configuration:
95+
96+
```yaml
97+
apiVersion: serving.knative.dev/v1
98+
kind: Service
99+
metadata:
100+
name: event-failure-capture
101+
spec:
102+
template:
103+
spec:
104+
containers:
105+
- image: docker.io/n3wscott/sockeye:v0.7.0@sha256:e603d8494eeacce966e57f8f508e4c4f6bebc71d095e3f5a0a1abaf42c5f0e48
62106
```
63107

64-
### Example Broker Configuration
108+
### Step 6: Review and Apply
65109

66-
Lets take a look at an example of a Broker with a dead letter sink and configure a simple bridge with a dead letter sink. For our discussion, let us consider [this example Bridge](../assets/yamlexamples/simple-bridge.yaml) as a starting point:
110+
Now that we have created all the necessary objects, we can review and apply the changes to the cluster. A concatenation of all the YAML objects is shown below:
67111

68112
```yaml
69113
apiVersion: eventing.knative.dev/v1
70114
kind: Broker
71115
metadata:
72116
name: events
117+
spec:
118+
delivery:
119+
deadLetterSink:
120+
ref:
121+
apiVersion: serving.knative.dev/v1
122+
kind: Service
123+
name: event-failure-capture
124+
backoffDelay: "PT0.5S" # or ISO8601 duration
125+
backoffPolicy: exponential # or linear
126+
retry: 2
127+
73128
---
129+
74130
apiVersion: sources.knative.dev/v1
75131
kind: PingSource
76132
metadata:
@@ -83,52 +139,137 @@ spec:
83139
apiVersion: eventing.knative.dev/v1
84140
kind: Broker
85141
name: events
86-
```
87-
88-
Now, lets modify this example to add a dead letter sink to the `Broker`. We can accomplish this in two steps:
89-
90-
1. Add a service to catch the "dead letter" events. (We will be using `Sockeye` here, but in a production scenario you would want to use something like SQS, Kafka, or another Sink that has some form of persistence.)
91142
92-
```yaml
93143
---
144+
94145
apiVersion: serving.knative.dev/v1
95146
kind: Service
96147
metadata:
97-
name: sockeye
148+
name: event-failure-capture
98149
spec:
99150
template:
100151
spec:
101152
containers:
102153
- image: docker.io/n3wscott/sockeye:v0.7.0@sha256:e603d8494eeacce966e57f8f508e4c4f6bebc71d095e3f5a0a1abaf42c5f0e48
103-
```
104-
105-
2. Update the `Broker` section to the following:
106154
107-
```yaml
108155
---
156+
109157
apiVersion: eventing.knative.dev/v1
110-
kind: Broker
158+
kind: Trigger
111159
metadata:
112-
name: events
160+
name: failtest
113161
spec:
114-
delivery:
115-
deadLetterSink:
162+
broker: events
163+
subscriber:
116164
ref:
117-
apiVersion: serving.knative.dev/v1
118-
kind: Service
119-
name: sockeye
120-
backoffDelay: "PT0.5S" # or ISO8601 duration
121-
backoffPolicy: exponential # or linear
122-
retry: 2
165+
apiVersion: serving.knative.dev/v1
166+
kind: Service
167+
name: event-display
168+
169+
---
170+
171+
apiVersion: serving.knative.dev/v1
172+
kind: Service
173+
metadata:
174+
name: event-display
175+
spec:
176+
template:
177+
spec:
178+
containers:
179+
- image: docker.io/n3wscott/sockeye:v0.7.0@sha256:e603d8494eeacce966e57f8f508e4c4f6bebc71d095e3f5a0a1abaf42c5f0e48
180+
name: user-container
123181
```
124182

125-
## Viewing the Results of a Dead Letter Sink
183+
Apply these changes to the cluster.
184+
185+
186+
### Step 7: Test the Bridge
126187

127-
Now that we have all the parts in place, we can monitor the events that are being sent to the dead letter sink. We can do this in two ways:
188+
Now with everything in place if we retrieve the current pods in the namespace of deployment, we should see our `event-display` and `event-failure-capture` services running.
189+
190+
191+
```cmd
192+
$ kubectl get pods
193+
NAME READY STATUS RESTARTS AGE
194+
event-display-00001-deployment-689f6d648d-tx4r5 2/2 Running 0 34s
195+
sockeye-00001-deployment-6f488dcd5b-w8zmb 2/2 Running 0 34s
196+
```
128197

129-
1. View the pod logs of the `sockeye` service:
130-
* `kubectl get pods` will show the pods that are running. Retrieve the sockeye pod name from the output.
131-
* `kubectl logs <SOCKEYE_POD_NAME> user-container` By replacing the `<SOCKEYE_POD_NAME>` with the pod name you can view the logs of the sockeye pod.
198+
After 60 secconds we should see the `event-failure-capture` service spin down, leaving us with only the `event-display` service running.
132199

133-
2. View the web service exposed by the `sockeye` service:
134-
* `kubectl get ksvc` will show the KSVC's that are running. Retrieve the sockeye public URL from the `URL` column and navigate to it in your browser.
200+
```cmd
201+
$ kubectl get pods
202+
NAME READY STATUS RESTARTS AGE
203+
event-display-00001-deployment-689f6d648d-tx4r5 2/2 Running 0 2m
204+
```
205+
206+
View the logs of the `event-display` service, to verify that the events are being recieved from the [PingSource](https://knative.dev/docs/eventing/sources/ping-source/) object.
207+
208+
```cmd
209+
$ kubectl logs event-display-00001-deployment-689f6d648d-tx4r5 user-container
210+
211+
2022/05/31 20:45:00 Broadasting to 0 clients: {"data":{"name":"triggermesh"},"id":"0e429ad9-cf9d-451d-98ce-886fa92acc35","knativearrivaltime":"2022-05-31T20:45:00.250764419Z","source":"/apis/v1/namespaces/delme/pingsources/ping-sockeye","specversion":"1.0","time":"2022-05-31T20:45:00.250270401Z","type":"dev.knative.sources.ping"}
212+
got Validation: valid
213+
Context Attributes,
214+
specversion: 1.0
215+
type: dev.knative.sources.ping
216+
source: /apis/v1/namespaces/delme/pingsources/ping-sockeye
217+
id: 5c448228-f413-4cbd-b9a4-1c1472c1b96a
218+
time: 2022-05-31T20:46:00.135993596Z
219+
Extensions,
220+
knativearrivaltime: 2022-05-31T20:46:00.136447484Z
221+
Data,
222+
{"name": "triggermesh"}
223+
224+
```
225+
226+
Here we can see that the events are being delivered and the [Bridge](https://docs.triggermesh.io/concepts/) is functioning properly.
227+
228+
229+
### Step 8: Break the Bridge
230+
231+
Break the [Bridge](https://docs.triggermesh.io/concepts/) by removing the `event-display` [Service](https://github.com/knative/specs/blob/main/specs/serving/knative-api-specification-1.0.md#service).
232+
233+
```yaml
234+
apiVersion: serving.knative.dev/v1
235+
kind: Service
236+
metadata:
237+
name: event-display
238+
spec:
239+
template:
240+
spec:
241+
containers:
242+
- image: docker.io/n3wscott/sockeye:v0.7.0@sha256:e603d8494eeacce966e57f8f508e4c4f6bebc71d095e3f5a0a1abaf42c5f0e48
243+
name: user-container
244+
```
245+
246+
247+
### Step 9: View the Events in the Dead Letter Sink
248+
249+
Now that our [Bridge](https://docs.triggermesh.io/concepts/) is broken, if we view the current pods we find that the `event-display` [Service](https://github.com/knative/specs/blob/main/specs/serving/knative-api-specification-1.0.md#service) has been removed, and our `event-failure-capture` [Service](https://github.com/knative/specs/blob/main/specs/serving/knative-api-specification-1.0.md#service) has spun up.
250+
251+
```cmd
252+
$ kubectl get pods
253+
NAME READY STATUS RESTARTS AGE
254+
sockeye-00001-deployment-6f488dcd5b-w8zmb 2/2 Running 0 34s
255+
```
256+
257+
Retrieve the logs to view the, would be, lost events.
258+
259+
```cmd
260+
$ kubectl logs sockeye-00001-deployment-6f488dcd5b-w8zmb user-container
261+
262+
2022/05/31 20:45:00 Broadasting to 0 clients: {"data":{"name":"triggermesh"},"id":"0e429ad9-cf9d-451d-98ce-886fa92acc35","knativearrivaltime":"2022-05-31T20:45:00.250764419Z","source":"/apis/v1/namespaces/delme/pingsources/ping-sockeye","specversion":"1.0","time":"2022-05-31T20:45:00.250270401Z","type":"dev.knative.sources.ping"}
263+
got Validation: valid
264+
Context Attributes,
265+
specversion: 1.0
266+
type: dev.knative.sources.ping
267+
source: /apis/v1/namespaces/delme/pingsources/ping-sockeye
268+
id: 5c448228-f413-4cbd-b9a4-1c1472c1b96a
269+
time: 2022-05-31T20:46:00.135993596Z
270+
Extensions,
271+
knativearrivaltime: 2022-05-31T20:46:00.136447484Z
272+
Data,
273+
{"name": "triggermesh"}
274+
275+
```

0 commit comments

Comments
 (0)