Skip to content

Commit caeb57d

Browse files
committed
refactor: Updating Eventing and Chapter
- eventing show two architectural types source to service and source to subscriber - build chapters reorganized Fixes #27
1 parent f55d3d3 commit caeb57d

10 files changed

Lines changed: 379 additions & 122 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: sources.eventing.knative.dev/v1alpha1
2+
kind: CronJobSource
3+
metadata:
4+
name: event-greeter-cronjob-source
5+
spec:
6+
schedule: "* * * * *"
7+
data: '{"message": "Thanks for doing Knative Tutorial"}'
8+
sink:
9+
apiVersion: serving.knative.dev/v1alpha1
10+
kind: Service
11+
name: event-greeter

documentation/modules/ROOT/nav.adoc

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -54,48 +54,60 @@
5454
*** xref:03scaling.adoc#scaling-deploy-service-minscale[Deploy service ]
5555
** xref:03scaling.adoc#scaling-cleanup[Cleanup]
5656
57-
* xref:04build.adoc[5. Build]
58-
** xref:04build.adoc#build-prerequisite[Prerequisites]
59-
*** xref:04build.adoc#build-create-docker-secret[Generate Docker Secret]
60-
*** xref:04build.adoc#build-generate-build-spec[Generate Build Spec]
61-
*** xref:04build.adoc#build-generate-knative-service[Generate Knative service]
62-
*** xref:04build.adoc#build-apply-preeq-resouces[Apply Resources]
63-
** xref:04build.adoc#build-create-build[Create Build]
64-
** xref:04build.adoc#build-see-what-you-have-deployed[See what you have deployed]
65-
** xref:04build.adoc#build-watching-logs[Watching logs]
66-
** xref:04build.adoc#build-build-status[Build Status]
67-
** xref:04build.adoc#build-deploy-service-build[Deploy Service]
68-
** xref:04build.adoc#build-invoke-service[Invoke Service]
69-
** xref:04build.adoc#build-build-cleanup[Cleanup]
57+
* xref:04build/build.adoc[5. Build]
58+
** xref:04build/build.adoc#build-prerequisite[Prerequisites]
59+
*** xref:04build/build.adoc#build-create-docker-secret[Generate Docker Secret]
60+
*** xref:04build/build.adoc#build-generate-build-spec[Generate Build Spec]
61+
*** xref:04build/build.adoc#build-generate-knative-service[Generate Knative service]
62+
*** xref:04build/build.adoc#build-apply-prereq-resources[Apply Resources]
63+
** xref:04build/build.adoc#build-create-build[Create Build]
64+
** xref:04build/build.adoc#build-see-what-you-have-deployed[See what you have deployed]
65+
** xref:04build/build.adoc#build-watching-logs[Watching logs]
66+
** xref:04build/build.adoc#build-build-status[Build Status]
67+
** xref:04build/build.adoc#build-deploy-service-build[Deploy Service]
68+
** xref:04build/build.adoc#build-invoke-service[Invoke Service]
69+
** xref:04build/build.adoc#build-build-cleanup[Cleanup]
7070
71-
* xref:05build-templates.adoc[6. Build Template]
72-
** xref:05build-templates.adoc#build-template-prerequisite[Prerequisites]
73-
*** xref:05build-templates.adoc#build-template-generate-template[Generate build template]
74-
*** xref:05build-templates.adoc#build-template-generate-service[Generate Knative service]
75-
*** xref:05build-templates.adoc#build-template-apply-resources[Apply Resources]
76-
** xref:05build-templates.adoc#build-template-create-template[Create Build Template]
77-
*** xref:05build-templates.adoc#build-see-what-you-have-deployed[See what you have deployed]
78-
** xref:05build-templates.adoc#build-deploy-service-build-template[Deploy Service]
79-
** xref:05build-templates.adoc#build-template-invoke-service[Invoke Service]
80-
** xref:05build-templates.adoc#build-template-cleanup[Cleanup]
71+
* xref:04build/build-templates.adoc[6. Build Template]
72+
** xref:04build/build-templates.adoc#build-template-prerequisite[Prerequisites]
73+
*** xref:04build/build-templates.adoc#build-template-generate-template[Generate build template]
74+
*** xref:04build/build-templates.adoc#build-template-generate-service[Generate Knative service]
75+
*** xref:04build/build-templates.adoc#build-template-apply-resources[Apply Resources]
76+
** xref:04build/build-templates.adoc#build-template-create-template[Create Build Template]
77+
*** xref:04build/build-templates.adoc#build-see-what-you-have-deployed[See what you have deployed]
78+
** xref:04build/build-templates.adoc#build-deploy-service-build-template[Deploy Service]
79+
** xref:04build/build-templates.adoc#build-template-invoke-service[Invoke Service]
80+
** xref:04build/build-templates.adoc#build-template-cleanup[Cleanup]
8181
82-
* xref:06eventing.adoc[7. Eventing]
83-
** xref:06eventing.adoc#eventing-prerequisite[Prerequisites]
84-
** xref:06eventing.adoc#eventing-channel[Channel]
85-
*** xref:06eventing.adoc#eventing-create-event-channel[Create Event Channel]
86-
*** xref:06eventing.adoc#eventing-verify-event-channel[Verify]
87-
** xref:06eventing.adoc#eventing-source[Event Source]
88-
*** xref:06eventing.adoc#eventing-create-event-source[Create Event Source]
89-
*** xref:06eventing.adoc#eventing-verify-event-source[Verify]
90-
** xref:06eventing.adoc#eventing-subscriber[Event Subscriber]
91-
*** xref:06eventing.adoc#eventing-create-subscriber[Create Event Subscriber]
92-
*** xref:06eventing.adoc#eventing-verify-subscriber[Verify]
93-
** xref:06eventing.adoc#eventing-see-what-you-have-deployed[See what you have deployed]
94-
** xref:06eventing.adoc#eventing-subscriber-service[Subscriber Service]
95-
*** xref:06eventing.adoc#eventing-gen-subscriber-service[Generate Service]
96-
*** xref:06eventing.adoc#eventing-deploy-subscriber-service[Deploy Service]
97-
** xref:06eventing.adoc#eventing-watch-logs[Watching Logs]
98-
** xref:06eventing.adoc#eventing-cleanup[Cleanup]
82+
* xref:05eventing/eventing.adoc[7. Eventing]
83+
** xref:05eventing/eventing.adoc#eventing-prerequisite[Prerequisites]
84+
** xref:05eventing/eventing.adoc#eventing-assumptions[Assumptions]
85+
** xref:05eventing/eventing.adoc#eventing-watch-logs[Watching Logs]
86+
** xref:05eventing/eventing-src-svc.adoc[Source to Service]
87+
*** xref:05eventing/eventing-src-svc.adoc#eventing-source[Event Source]
88+
*** xref:05eventing/eventing-src-svc.adoc#eventing-create-event-source[Create Event Source]
89+
*** xref:05eventing/eventing-src-svc.adoc#eventing-verify-event-source[Verify]
90+
*** xref:05eventing/eventing-src-svc.adoc#eventing-sink-service[Sink Service]
91+
**** xref:05eventing/eventing-src-svc.adoc#eventing-gen-sink-service[Generate Service]
92+
**** xref:05eventing/eventing-src-svc.adoc#eventing-deploy-sink-service[Deploy Service]
93+
*** xref:05eventing/eventing-src-svc.adoc#eventing-see-what-you-have-deployed[See what you have deployed]
94+
*** xref:05eventing/eventing-src-svc.adoc#eventing-cleanup[Cleanup]
95+
96+
** xref:05eventing/eventing-src-sub.adoc[Source to Subscriber]
97+
*** xref:05eventing/eventing-src-sub.adoc#eventing-channel[Channel]
98+
**** xref:05eventing/eventing-src-sub.adoc#eventing-create-event-channel[Create Event Channel]
99+
**** xref:05eventing/eventing-src-sub.adoc#eventing-verify-event-channel[Verify]
100+
*** xref:05eventing/eventing-src-sub.adoc#eventing-source[Event Source]
101+
**** xref:05eventing/eventing-src-sub.adoc#eventing-create-event-source[Create Event Source]
102+
**** xref:05eventing/eventing-src-sub.adoc#eventing-verify-event-source[Verify]
103+
*** xref:05eventing/eventing-src-sub.adoc#eventing-subscriber[Event Subscriber]
104+
**** xref:05eventing/eventing-src-sub.adoc#eventing-create-subscriber[Create Event Subscriber]
105+
**** xref:05eventing/eventing-src-sub.adoc#eventing-verify-subscriber[Verify]
106+
*** xref:05eventing/eventing-src-sub.adoc#eventing-see-what-you-have-deployed[See what you have deployed]
107+
*** xref:05eventing/eventing-src-sub.adoc#eventing-subscriber-service[Subscriber Service]
108+
**** xref:05eventing/eventing-src-sub.adoc#eventing-gen-subscriber-service[Generate Service]
109+
**** xref:05eventing/eventing-src-sub.adoc#eventing-deploy-subscriber-service[Deploy Service]
110+
*** xref:05eventing/eventing-src-sub.adoc#eventing-cleanup[Cleanup]
99111
100112
101113
* xref:faq.adoc[Frequently Asked Questions]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include::../_attributes.adoc[]

documentation/modules/ROOT/pages/05build-templates.adoc renamed to documentation/modules/ROOT/pages/04build/build-templates.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Build Template
22
include::_attributes.adoc[]
33

4-
The raw builds like what we did in xref:ROOT:04build.adoc[previous chapter] has some disadvantages:
4+
The raw builds like what we did in xref:ROOT:04build/build.adoc[previous chapter] has some disadvantages:
55

66
* No reusability
77
* Hard coding of build parameters
@@ -17,9 +17,9 @@ include::partial$prereq-cli.adoc[]
1717

1818
[IMPORTANT]
1919
====
20-
* Please ensure that you have xref:ROOT:04build.adoc#build-registry-account[ registry account] created.
20+
* Please ensure that you have xref:ROOT:04build/build.adoc#build-registry-account[ registry account] created.
2121
22-
* Pre-requisite xref:ROOT:04build.adoc#build-apply-preeq-resouces[kubernetes resources] have been created and applied.
22+
* Pre-requisite xref:ROOT:04build/build.adoc#build-apply-prereq-resources[kubernetes resources] have been created and applied.
2323
====
2424

2525
[#build-template-generate-template]
@@ -94,7 +94,7 @@ spec:
9494

9595
<1> The build template does not have any hard-coded values, *the dynamic values could be passed using **parameters** of the template.
9696

97-
The build done by the build steps of the template is exactly same like what was done by xref:ROOT:04build.adoc#build-create-build[raw build], but templates gives flexibility and ease of configuration via parameters. The template step(s) modifications are transparent to the consumers (the builds inheriting the template), the builds using the template will automatically inherit the modified steps.
97+
The build done by the build steps of the template is exactly same like what was done by xref:ROOT:04build/build.adoc#build-create-build[raw build], but templates gives flexibility and ease of configuration via parameters. The template step(s) modifications are transparent to the consumers (the builds inheriting the template), the builds using the template will automatically inherit the modified steps.
9898

9999
[#build-template-generate-service]
100100
=== Generate Knative service
@@ -165,7 +165,7 @@ spec:
165165
[#build-template-apply-resources]
166166
=== Apply resources
167167

168-
As we have already xref:ROOT:04build.adoc#build-apply-preeq-resouces[applied the pre-req] resources, lets jump straight to applying the template and service.
168+
As we have already xref:ROOT:04build/build.adoc#build-apply-prereq-resources[applied the pre-req] resources, lets jump straight to applying the template and service.
169169

170170
Navigate to the tutorial chapter's `knative` folder:
171171

@@ -216,7 +216,7 @@ oc apply -n knativetutorial -f service-with-build-template.yaml
216216
----
217217

218218

219-
You can also xref:ROOT:04build.adoc#build-watching-logs[watch the logs] of the build triggered with the service deployment.
219+
You can also xref:ROOT:04build/build.adoc#build-watching-logs[watch the logs] of the build triggered with the service deployment.
220220

221221
After successful deployment of the service we should see a kubernetes deployment called `event-greeter-00001-deployment` available.
222222

@@ -271,4 +271,4 @@ oc -n knativetutorial delete services.serving.knative.dev event-greeter
271271
oc -n knativetutorial delete buildtemplates.build.knative.dev build-java-maven
272272
----
273273

274-
NOTE: You can also delete xref:ROOT:04build.adoc#build-apply-preeq-resouces[pre-req resources] that were created if you dont need them any more.
274+
NOTE: You can also delete xref:ROOT:04build/build.adoc#build-apply-prereq-resources[pre-req resources] that were created if you dont need them any more.

documentation/modules/ROOT/pages/04build.adoc renamed to documentation/modules/ROOT/pages/04build/build.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ spec:
189189

190190
<1> Set from `image` parameter -- the fully qualified container image that will be pushed to the registry as part of the build --
191191

192-
[#build-apply-preeq-resouces]
192+
[#build-apply-prereq-resources]
193193
=== Apply pre-requisite resources
194194

195195
Navigate to the tutorial chapter's `knative` folder:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include::../_attributes.adoc[]

documentation/modules/ROOT/pages/06eventing.adoc renamed to documentation/modules/ROOT/pages/05eventing/eventing-src-sub.adoc

Lines changed: 4 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
1-
= Eventing
1+
= Eventing - Source to Subscriber
22
include::_attributes.adoc[]
33

4-
At the end of this chapter you will know and understand:
5-
6-
* What is an event source ?
7-
* What is a channel ?
8-
* What is a subscriber ?
9-
* How to make a service a subscriber of an event ?
10-
11-
[#eventing-prerequisite]
12-
== Prerequisite
13-
include::partial$prereq-cli.adoc[]
14-
15-
=== Assumption
16-
17-
You have completed the xref:ROOT:04build.adoc[Build] or xref:ROOT:05build-templates.adoc[Build Templates], as you will be using the container image `event-greeter:0.0.1` or `event-greeter:0.0.2` in this chapter.
18-
194
[#eventing-channel]
205
== Channel(Sink)
216

227
The https://en.wikipedia.org/wiki/Event-driven_architecture#Event_channel[channel or sink] is an interface between the <<eventing-source,event source>> and the <<eventing-subscriber,subscriber>>.The channels are built in to store the incoming events and distribute the event data to the subscribers. When forwarding event to subscribers the channel transforms the event data as per http://cloudevents.io[CloudEvent] specification.
238

249
[#eventing-create-event-channel]
2510
=== Create Event Channel
26-
[.text-center]
2711
.link:{github-repo}/{eventing-repo}/knative/channel.yaml[channel.yaml][channel-subscriber.yaml]
2812
[source,yaml,linenums]
2913
----
@@ -99,7 +83,7 @@ The event source listens to external events e.g. a kafka topic or for a file on
9983
apiVersion: sources.eventing.knative.dev/v1alpha1
10084
kind: CronJobSource #<1>
10185
metadata:
102-
name: test-cronjob-source
86+
name: event-greeter-cronjob-source
10387
spec:
10488
schedule: "* * * * *"
10589
data: '{"message": "Thanks for doing the Knative Tutorial"}'
@@ -117,7 +101,7 @@ spec:
117101
Event Source can define the attributes that it wishes to receive via the
118102
spec. In the above example it defines **schedule**(the the cron expression) and **data** that will be sent as part of the event.
119103

120-
When you <<eventing-watch-logs,watch the logs>>, you will notice this data being delivered to the service.
104+
When you xref:05eventing/eventing.adoc#eventing-watch-logs[watch logs], you will notice this data being delivered to the service.
121105
====
122106

123107
Run the following commands to create the event source resources:
@@ -339,60 +323,6 @@ kubectl apply -n knativetutorial -f service.yaml
339323
oc apply -n knativetutorial -f service.yaml
340324
----
341325

342-
[#eventing-watch-logs]
343-
== Watching Logs
344-
345-
Since it is a Cron job source, it would have started to emit events every minute. We can watch the logs of the service to see the messages delivered.
346-
347-
The logs could be watched using the command:
348-
349-
[source,bash,subs="+macros,+attributes"]
350-
----
351-
kubectl logs -n knativetutorial -f <pod-name> -c user-container
352-
----
353-
354-
.(OR)
355-
356-
[source,bash,subs="+macros,+attributes"]
357-
----
358-
oc logs -n knativetutorial -f <pod-name> -c user-container
359-
----
360-
361-
[TIP]
362-
====
363-
* Using stern with the command `stern -n knativetutorial event-greeter`, to filter the logs further add `-c user-container` to the stern command.
364-
365-
[source,bash,subs="+macros,+attributes"]
366-
----
367-
stern -n knativetutorial -c user-container event-greeter
368-
----
369-
====
370-
371-
The logs will have the output like below printing every minute.
372-
373-
[source]
374-
----
375-
2019-02-07 14:07:00.011 INFO 1 --- [-server-epoll-6] com.example.demo.EventGreeterController : Event Message Received {
376-
"ID" : "1549548420001445196-715",
377-
"EventTime" : "2019-02-07T14:07:00.001470981Z",
378-
"Body" : "{\"message\": \"Thanks for doing Knative Tutorial\"}",
379-
"host" : "Event greeter => 'event-greeter-00001-deployment-84f879ff6d-88rxb' : 3 ",
380-
"time" : "14:07:00"
381-
}
382-
----
383-
[.text-center]
384-
(OR)
385-
[source]
386-
----
387-
2019-02-07 14:07:00.011 INFO 1 --- [-server-epoll-6] com.example.demo.EventGreeterController : Event Message Received {
388-
"ID" : "1549548420001445196-715",
389-
"EventTime" : "2019-02-07T14:07:00.001470981Z",
390-
"Body" : "{\"message\": \"Thanks for doing Knative Tutorial\"}",
391-
"host" : "Event greeter v0.0.2 => 'event-greeter-00001-deployment-84f879ff6d-88rxb' : 3 ",
392-
"time" : "14:07:00"
393-
}
394-
----
395-
396326
[#eventing-cleanup]
397327
== Cleanup
398328

@@ -416,4 +346,4 @@ oc -n knativetutorial delete channels.eventing.knative.dev ch-event-greeter
416346
oc -n knativetutorial delete subscriptions.eventing.knative.dev event-greeter-subscriber
417347
----
418348

419-
NOTE: You can also delete xref:ROOT:04build.adoc#build-apply-preeq-resouces[pre-req resources] that were created if you dont need them any more.
349+
NOTE: You can also delete xref:ROOT:04build/build.adoc#build-apply-prereq-resources[pre-req resources] that were created if you dont need them any more.

0 commit comments

Comments
 (0)