Skip to content

Commit b37ea97

Browse files
authored
Fix Brokers and Triggers section about using the correct filter for each event trigger (#289)
1 parent b94dd79 commit b37ea97

File tree

4 files changed

+14
-82
lines changed

4 files changed

+14
-82
lines changed

documentation/modules/eventing/examples/eventing/trigger-helloaloha.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ kind: Trigger
33
metadata:
44
name: helloaloha
55
spec:
6+
broker: default
67
filter:
78
attributes:
8-
type: greeting
9+
type: aloha
910
subscriber:
1011
ref:
1112
apiVersion: serving.knative.dev/v1

documentation/modules/eventing/examples/eventing/trigger-hellobonjour.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ spec:
66
broker: default
77
filter:
88
attributes:
9-
type: greeting
9+
type: bonjour
1010
subscriber:
1111
ref:
1212
apiVersion: serving.knative.dev/v1

documentation/modules/eventing/pages/_partials/deploy-knative-resources.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ kn subscription create eventinghellob-sub \
8888
kn trigger create {trigger-name} \
8989
--broker=default \
9090
--sink=ksvc:{trigger-sub-name} \
91-
--filter=type=greeting
91+
--filter=type={trigger-event}
9292
----
9393
#end::eventing-trigger-sub[]
9494
#tag::tab-2[]

documentation/modules/eventing/pages/eventing-trigger-broker.adoc

Lines changed: 10 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ spec:
8383
broker: default
8484
filter:
8585
attributes:
86-
type: greeting # <1>
86+
type: aloha # <1>
8787
subscriber:
8888
ref:
8989
apiVersion: serving.knative.dev/v1
@@ -98,12 +98,14 @@ Now create the the trigger for `eventingaloha` that will associate the filtered
9898
:service-file: trigger-helloaloha.yaml
9999
:trigger-name: helloaloha
100100
:trigger-sub-name: eventingaloha
101+
:trigger-event: aloha
101102
=== Create Aloha Trigger
102103
include::eventing:partial$deploy-knative-resources.adoc[tags=tab-1;eventing-trigger-sub;tab-2]
103104

104105
:service-file: trigger-hellobonjour.yaml
105106
:trigger-name: hellobonjour
106107
:trigger-sub-name: eventingbonjour
108+
:trigger-event: bonjour
107109
=== Create Bonjour Trigger
108110
Now create the the trigger for `eventingbonjour` that will associate the filtered events to a service:
109111

@@ -124,39 +126,7 @@ include::eventing:partial$knative-objects.adoc[tag=knative-triggers]
124126
[#eventing-trigger-verification]
125127
== Verification
126128

127-
Pull out the subscriberUri for `eventhingaloha`:
128-
129-
[#eventing-triggers-verify-sub1]
130-
[.console-input]
131-
[source,bash,subs="+macros,+attributes"]
132-
----
133-
kubectl get trigger helloaloha -o jsonpath='{.status.subscriberUri}'
134-
----
135-
136-
The command should show the output as:
137-
[.console-output]
138-
[source,bash]
139-
----
140-
http://eventingaloha.knativetutorial.svc.cluster.local
141-
----
142-
143-
Pull out the subscriberUri for `eventhingbonjour`:
144-
145-
[#eventing-triggers-verify-sub2]
146-
[.console-input]
147-
[source,bash,subs="+macros,+attributes"]
148-
----
149-
kubectl get trigger hellobonjour -o jsonpath='{.status.subscriberUri}'
150-
----
151-
152-
The command should show the output as:
153-
[.console-output]
154-
[source,bash]
155-
----
156-
http://eventingbonjour.knativetutorial.svc.cluster.local
157-
----
158-
159-
As well as broker's subscriberUri:
129+
Pull out the broker URI:
160130

161131
[#eventing-triggers-verify-sub3]
162132
[.console-input]
@@ -172,7 +142,7 @@ The command should show the output as:
172142
http://broker-ingress.knative-eventing.svc.cluster.local/{tutorial-namespace}/default
173143
----
174144

175-
You should notice that the subscriberURIs are Kubernetes services with the suffix of `{tutorial-namespace}.svc.cluster.local`. This means they can be interacted with from another pod within the Kubernetes cluster.
145+
You should notice that the broker URI is a Kubernetes services with the suffix of `{tutorial-namespace}.svc.cluster.local`. This means they can be interacted with from another pod within the Kubernetes cluster.
176146

177147
Now that you have setup the Broker and Triggers you need to send in some test messages to see the behavior.
178148

@@ -221,12 +191,12 @@ Exec into the `curler` pod:
221191
kubectl -n {tutorial-namespace} exec -it curler -- /bin/bash
222192
----
223193

224-
Using the `curler` pod's shell, curl the subcriberURI for eventingaloha:
194+
Using the `curler` pod's shell, curl the broker URI for eventingaloha:
225195

226196
[.console-input]
227197
[source,bash,subs="+macros,+attributes"]
228198
----
229-
curl -v "http://eventingaloha.{tutorial-namespace}.svc.cluster.local" \
199+
curl -v "http://broker-ingress.{tutorial-namespace}.svc.cluster.local" \
230200
-X POST \
231201
-H "Ce-Id: say-hello" \
232202
-H "Ce-Specversion: 1.0" \
@@ -255,12 +225,12 @@ curler 1/1 Running 59s
255225
eventingaloha-1-deployment-6cdc888d9d-9xnnn 2/2 Running 30s
256226
-----
257227

258-
Next, curl the subcriberURI for `eventingbonjour`:
228+
Next, curl the broker URI for `eventingbonjour`:
259229

260230
[.console-input]
261231
[source,bash,subs="+macros,+attributes"]
262232
----
263-
curl -v "http://eventingbonjour.{tutorial-namespace}.svc.cluster.local" \
233+
curl -v "http://broker-ingress.{tutorial-namespace}.svc.cluster.local" \
264234
-X POST \
265235
-H "Ce-Id: say-hello" \
266236
-H "Ce-Specversion: 1.0" \
@@ -290,46 +260,7 @@ eventingaloha-1-deployment-6cdc888d9d-9xnnn 2/2 Running 53s
290260
eventingbonjour-1-deployment-fc7858b5b-s9prj 2/2 Running 5s
291261
-----
292262

293-
Now, trigger both `eventingaloha` and `eventingbonjour` by curling the subcriberURI for the broker:
294-
295-
[#trigger-verify-trigger-all]
296-
[.console-input]
297-
[source,bash,subs="+macros,+attributes"]
298-
----
299-
curl -v "http://broker-ingress.knative-eventing.svc.cluster.local/{tutorial-namespace}/default" \
300-
-X POST \
301-
-H "Ce-Id: say-hello" \
302-
-H "Ce-Specversion: 1.0" \
303-
-H "Ce-Type: greeting" \
304-
-H "Ce-Source: mycurl" \
305-
-H "Content-Type: application/json" \
306-
-d '{"key":"from a curl"}'
307-
----
308-
309-
[NOTE]
310-
====
311-
"Ce-Type: greeting" is the key to insuring that both aloha and bonjour respond to this event
312-
====
313-
314-
And by watching the *{tutorial-namespace}* namespace, you will see both `eventingaloha` and `eventingbonjour` will come to life:
315-
316-
[#trigger-watch-all-scale]
317-
[.console-input]
318-
[source,bash,subs="+macros,+attributes"]
319-
-----
320-
watch kubectl get pods
321-
-----
322-
323-
The command above should show the following output:
324-
325-
[.console-output]
326-
[source,bash]
327-
-----
328-
NAME READY STATUS AGE
329-
curler 1/1 Running 3m21s
330-
eventingaloha-1-deployment-6cdc888d9d-nlpm8 2/2 Running 6s
331-
eventingbonjour-1-deployment-fc7858b5b-btdcr 2/2 Running 6s
332-
-----
263+
It was verified how each payload configured with either `type: aloha` or `type: bonjour` sent to the broker, then each trigger was able to filter each incoming message and send to the designated service set in the trigger.
333264

334265
You can experiment by using different type filters in the Subscription to see how the different subscribed services respond. `Filters` may use an link:https://cloudevents.io/[CloudEvent] attribute for its criteria.
335266

0 commit comments

Comments
 (0)