diff --git a/docs/eventing/samples/sequence/sequence-reply-to-event-display/README.md b/docs/eventing/samples/sequence/sequence-reply-to-event-display/README.md index 47fe24469..eb910a9fa 100644 --- a/docs/eventing/samples/sequence/sequence-reply-to-event-display/README.md +++ b/docs/eventing/samples/sequence/sequence-reply-to-event-display/README.md @@ -6,7 +6,7 @@ type: "docs" --- We are going to create the following logical configuration. We create a -CronJobSource, feeding events to a [`Sequence`](../../../sequence.md), then +PingSource, feeding events to a [`Sequence`](../../../flows/sequence.md), then taking the output of that `Sequence` and displaying the resulting output. ![Logical Configuration](./sequence-reply-to-event-display.png) @@ -86,13 +86,13 @@ If you are using a different type of Channel, you need to change the spec.channelTemplate to point to your desired Channel. ```yaml -apiVersion: flows.knative.dev/v1alpha1 +apiVersion: flows.knative.dev/v1beta1 kind: Sequence metadata: name: sequence spec: channelTemplate: - apiVersion: messaging.knative.dev/v1alpha1 + apiVersion: messaging.knative.dev/v1beta1 kind: InMemoryChannel steps: - ref: @@ -142,28 +142,28 @@ your resources to be created. kubectl -n default create -f ./event-display.yaml ``` -### Create the CronJobSource targeting the Sequence +### Create the PingSource targeting the Sequence -This will create a CronJobSource which will send a CloudEvent with {"message": +This will create a PingSource which will send a CloudEvent with {"message": "Hello world!"} as the data payload every 2 minutes. ```yaml -apiVersion: sources.eventing.knative.dev/v1alpha1 -kind: CronJobSource +apiVersion: sources.knative.dev/v1alpha1 +kind: PingSource metadata: - name: cronjob-source + name: ping-source spec: schedule: "*/2 * * * *" data: '{"message": "Hello world!"}' sink: ref: - apiVersion: flows.knative.dev/v1alpha1 + apiVersion: flows.knative.dev/v1beta1 kind: Sequence name: sequence ``` ```shell -kubectl -n default create -f ./cron-source.yaml +kubectl -n default create -f ./ping-source.yaml ``` ### Inspecting the results @@ -175,19 +175,22 @@ pods. kubectl -n default get pods ``` -Then look at the logs for the event-display pod: +Wait a bit and then look at the logs for the event-display pod: ```shell -kubectl -n default logs -l serving.knative.dev/service=event-display -c user-container +kubectl -n default logs -l serving.knative.dev/service=event-display -c user-container --tail=-1 ☁️ cloudevents.Event Validation: valid Context Attributes, - cloudEventsVersion: 0.1 - eventType: samples.http.mod3 - source: /transformer/2 - eventID: df52b47e-02fd-45b2-8180-dabb572573f5 - eventTime: 2019-06-18T14:18:42.478140635Z - contentType: application/json + specversion: 1.0 + type: samples.http.mode3 + source: /apis/v1/namespaces/default/pingsources/ping-source + id: e8fa7906-ab62-4e61-9c13-a9406e2130a9 + time: 2020-03-02T20:52:00.0004957Z + datacontenttype: application/json +Extensions, + knativehistory: sequence-kn-sequence-0-kn-channel.default.svc.cluster.local; sequence-kn-sequence-1-kn-channel.default.svc.cluster.local; sequence-kn-sequence-2-kn-channel.default.svc.cluster.local + traceparent: 00-6e2947379387f35ddc933b9190af16ad-de3db0bc4e442394-00 Data, { "id": 0, @@ -195,5 +198,5 @@ Data, } ``` -And you can see that the initial Cron Source message ("Hello World!") has been +And you can see that the initial PingSource message `("Hello World!")` has been appended to it by each of the steps in the Sequence. diff --git a/docs/eventing/samples/sequence/sequence-reply-to-event-display/event-display.yaml b/docs/eventing/samples/sequence/sequence-reply-to-event-display/event-display.yaml index ca8ab326c..63d234e98 100644 --- a/docs/eventing/samples/sequence/sequence-reply-to-event-display/event-display.yaml +++ b/docs/eventing/samples/sequence/sequence-reply-to-event-display/event-display.yaml @@ -6,4 +6,4 @@ spec: template: spec: containers: - - image: gcr.io/knative-releases/knative.dev/eventing-sources/cmd/event_display + - image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display diff --git a/docs/eventing/samples/sequence/sequence-reply-to-event-display/cron-source.yaml b/docs/eventing/samples/sequence/sequence-reply-to-event-display/ping-source.yaml similarity index 50% rename from docs/eventing/samples/sequence/sequence-reply-to-event-display/cron-source.yaml rename to docs/eventing/samples/sequence/sequence-reply-to-event-display/ping-source.yaml index 3a68fe4c4..fbe88b4cc 100644 --- a/docs/eventing/samples/sequence/sequence-reply-to-event-display/cron-source.yaml +++ b/docs/eventing/samples/sequence/sequence-reply-to-event-display/ping-source.yaml @@ -1,12 +1,12 @@ -apiVersion: sources.eventing.knative.dev/v1alpha1 -kind: CronJobSource +apiVersion: sources.knative.dev/v1alpha1 +kind: PingSource metadata: - name: cronjob-source + name: ping-source spec: schedule: "*/2 * * * *" data: '{"message": "Hello world!"}' sink: ref: - apiVersion: flows.knative.dev/v1alpha1 + apiVersion: flows.knative.dev/v1beta1 kind: Sequence name: sequence diff --git a/docs/eventing/samples/sequence/sequence-reply-to-event-display/sequence-reply-to-event-display.png b/docs/eventing/samples/sequence/sequence-reply-to-event-display/sequence-reply-to-event-display.png index 88e55b9b8..e65429cf0 100644 Binary files a/docs/eventing/samples/sequence/sequence-reply-to-event-display/sequence-reply-to-event-display.png and b/docs/eventing/samples/sequence/sequence-reply-to-event-display/sequence-reply-to-event-display.png differ diff --git a/docs/eventing/samples/sequence/sequence-reply-to-event-display/sequence.yaml b/docs/eventing/samples/sequence/sequence-reply-to-event-display/sequence.yaml index 7694c7503..966c2c604 100644 --- a/docs/eventing/samples/sequence/sequence-reply-to-event-display/sequence.yaml +++ b/docs/eventing/samples/sequence/sequence-reply-to-event-display/sequence.yaml @@ -1,10 +1,10 @@ -apiVersion: flows.knative.dev/v1alpha1 +apiVersion: flows.knative.dev/v1beta1 kind: Sequence metadata: name: sequence spec: channelTemplate: - apiVersion: messaging.knative.dev/v1alpha1 + apiVersion: messaging.knative.dev/v1beta1 kind: InMemoryChannel steps: - ref: diff --git a/docs/eventing/samples/sequence/sequence-reply-to-event-display/steps.yaml b/docs/eventing/samples/sequence/sequence-reply-to-event-display/steps.yaml index c8fe4563a..c8f408538 100644 --- a/docs/eventing/samples/sequence/sequence-reply-to-event-display/steps.yaml +++ b/docs/eventing/samples/sequence/sequence-reply-to-event-display/steps.yaml @@ -37,4 +37,6 @@ spec: env: - name: MESSAGE value: " - Handled by 2" + - name: TYPE + value: "samples.http.mod3" --- diff --git a/docs/eventing/samples/sequence/sequence-reply-to-sequence/README.md b/docs/eventing/samples/sequence/sequence-reply-to-sequence/README.md index 63a265aee..4fe0773c2 100644 --- a/docs/eventing/samples/sequence/sequence-reply-to-sequence/README.md +++ b/docs/eventing/samples/sequence/sequence-reply-to-sequence/README.md @@ -6,7 +6,7 @@ type: "docs" --- We are going to create the following logical configuration. We create a -CronJobSource, feeding events to a [`Sequence`](../../../sequence.md), then +PingSource, feeding events to a [`Sequence`](../../../flows/sequence.md), then taking the output of that `Sequence` and sending it to a second `Sequence` and finally displaying the resulting output. @@ -17,9 +17,9 @@ The functions used in these examples live in ## Prerequisites -For this example, we'll assume you have set up a an `InMemoryChannel` as well as +For this example, we'll assume you have set up an `InMemoryChannel` as well as Knative Serving (for our functions). The examples use `default` namespace, -again, if you want to deploy to another Namespace, you will need to modify the +again, if you want to deploy to another namespace, you will need to modify the examples to reflect this. If you want to use different type of `Channel`, you will have to modify the @@ -127,13 +127,13 @@ If you are using a different type of Channel, you need to change the spec.channelTemplate to point to your desired Channel. ```yaml -apiVersion: flows.knative.dev/v1alpha1 +apiVersion: flows.knative.dev/v1beta1 kind: Sequence metadata: name: first-sequence spec: channelTemplate: - apiVersion: messaging.knative.dev/v1alpha1 + apiVersion: messaging.knative.dev/v1beta1 kind: InMemoryChannel steps: - ref: @@ -169,13 +169,13 @@ If you are using a different type of Channel, you need to change the spec.channelTemplate to point to your desired Channel. ```yaml -apiVersion: flows.knative.dev/v1alpha1 +apiVersion: flows.knative.dev/v1beta1 kind: Sequence metadata: name: second-sequence spec: channelTemplate: - apiVersion: messaging.knative.dev/v1alpha1 + apiVersion: messaging.knative.dev/v1beta1 kind: InMemoryChannel steps: - ref: @@ -197,6 +197,11 @@ spec: name: event-display ``` + +```shell +kubectl -n default create -f ./sequence2.yaml +``` + ### Create the Service displaying the events created by Sequence ```yaml @@ -208,7 +213,7 @@ spec: template: spec: containerers: - - image: gcr.io/knative-releases/knative.dev/eventing-sources/cmd/event_display + - image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display ``` Change `default` below to create the `Sequence` in the Namespace where you want @@ -218,28 +223,28 @@ your resources created. kubectl -n default create -f ./event-display.yaml ``` -### Create the CronJobSource targeting the first Sequence +### Create the PingSource targeting the first Sequence -This will create a CronJobSource which will send a CloudEvent with {"message": -"Hello world!"} as the data payload every 2 minutes. +This will create a PingSource which will send a CloudEvent with `{"message": +"Hello world!"}` as the data payload every 2 minutes. ```yaml -apiVersion: sources.eventing.knative.dev/v1alpha1 -kind: CronJobSource +apiVersion: sources.knative.dev/v1alpha1 +kind: PingSource metadata: - name: cronjob-source + name: ping-source spec: schedule: "*/2 * * * *" data: '{"message": "Hello world!"}' sink: ref: - apiVersion: flows.knative.dev/v1alpha1 + apiVersion: flows.knative.dev/v1beta1 kind: Sequence name: first-sequence ``` ```shell -kubectl -n default create -f ./cron-source.yaml +kubectl -n default create -f ./ping-source.yaml ``` ### Inspecting the results @@ -254,16 +259,19 @@ kubectl -n default get pods Then look at the logs for the event-display pod: ```shell -kubectl -n default logs -l serving.knative.dev/service=event-display -c user-container +kubectl -n default logs -l serving.knative.dev/service=event-display -c user-container --tail=-1 ☁️ cloudevents.Event Validation: valid Context Attributes, - cloudEventsVersion: 0.1 - eventType: samples.http.mod3 - source: /transformer/5 - eventID: 7628a147-ec74-43d5-a888-8384a1b6b005 - eventTime: 2019-06-18T13:57:20.279354375Z - contentType: application/json + specversion: 1.0 + type: dev.knative.sources.ping + source: /apis/v1/namespaces/default/pingsources/ping-source + id: 29d531df-78d8-4d11-9ffd-ba24045241a9 + time: 2020-03-02T21:18:00.0011708Z + datacontenttype: application/json +Extensions, + knativehistory: first-sequence-kn-sequence-0-kn-channel.default.svc.cluster.local; first-sequence-kn-sequence-1-kn-channel.default.svc.cluster.local; first-sequence-kn-sequence-2-kn-channel.default.svc.cluster.local; second-sequence-kn-sequence-0-kn-channel.default.svc.cluster.local; second-sequence-kn-sequence-1-kn-channel.default.svc.cluster.local; second-sequence-kn-sequence-2-kn-channel.default.svc.cluster.local + traceparent: 00-e5abc9de525a89ead80560b8f328de5c-fc12b64a6296f541-00 Data, { "id": 0, @@ -271,5 +279,5 @@ Data, } ``` -And you can see that the initial Cron Source message ("Hello World!") has been +And you can see that the initial PingSource message `("Hello World!")` has been appended to it by each of the steps in the Sequence. diff --git a/docs/eventing/samples/sequence/sequence-reply-to-sequence/event-display.yaml b/docs/eventing/samples/sequence/sequence-reply-to-sequence/event-display.yaml index ca8ab326c..63d234e98 100644 --- a/docs/eventing/samples/sequence/sequence-reply-to-sequence/event-display.yaml +++ b/docs/eventing/samples/sequence/sequence-reply-to-sequence/event-display.yaml @@ -6,4 +6,4 @@ spec: template: spec: containers: - - image: gcr.io/knative-releases/knative.dev/eventing-sources/cmd/event_display + - image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display diff --git a/docs/eventing/samples/sequence/sequence-reply-to-sequence/cron-source.yaml b/docs/eventing/samples/sequence/sequence-reply-to-sequence/ping-source.yaml similarity index 51% rename from docs/eventing/samples/sequence/sequence-reply-to-sequence/cron-source.yaml rename to docs/eventing/samples/sequence/sequence-reply-to-sequence/ping-source.yaml index b54d9fe82..fb7c53982 100644 --- a/docs/eventing/samples/sequence/sequence-reply-to-sequence/cron-source.yaml +++ b/docs/eventing/samples/sequence/sequence-reply-to-sequence/ping-source.yaml @@ -1,12 +1,12 @@ -apiVersion: sources.eventing.knative.dev/v1alpha1 -kind: CronJobSource +apiVersion: sources.knative.dev/v1alpha1 +kind: PingSource metadata: - name: cronjob-source + name: ping-source spec: schedule: "*/2 * * * *" data: '{"message": "Hello world!"}' sink: ref: - apiVersion: flows.knative.dev/v1alpha1 + apiVersion: flows.knative.dev/v1beta1 kind: Sequence name: first-sequence diff --git a/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence-reply-to-sequence.png b/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence-reply-to-sequence.png index fc50cfbe2..fd9c01496 100644 Binary files a/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence-reply-to-sequence.png and b/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence-reply-to-sequence.png differ diff --git a/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence1.yaml b/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence1.yaml index 16b4564c2..23af8a947 100644 --- a/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence1.yaml +++ b/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence1.yaml @@ -1,10 +1,10 @@ -apiVersion: flows.knative.dev/v1alpha1 +apiVersion: flows.knative.dev/v1beta1 kind: Sequence metadata: name: first-sequence spec: channelTemplate: - apiVersion: messaging.knative.dev/v1alpha1 + apiVersion: messaging.knative.dev/v1beta1 kind: InMemoryChannel steps: - ref: @@ -22,5 +22,5 @@ spec: reply: ref: kind: Sequence - apiVersion: flows.knative.dev/v1alpha1 + apiVersion: flows.knative.dev/v1beta1 name: second-sequence diff --git a/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence2.yaml b/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence2.yaml index 213ab4714..78143c8cc 100644 --- a/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence2.yaml +++ b/docs/eventing/samples/sequence/sequence-reply-to-sequence/sequence2.yaml @@ -1,10 +1,10 @@ -apiVersion: flows.knative.dev/v1alpha1 +apiVersion: flows.knative.dev/v1beta1 kind: Sequence metadata: name: second-sequence spec: channelTemplate: - apiVersion: messaging.knative.dev/v1alpha1 + apiVersion: messaging.knative.dev/v1beta1 kind: InMemoryChannel steps: - ref: diff --git a/docs/eventing/samples/sequence/sequence-terminal/README.md b/docs/eventing/samples/sequence/sequence-terminal/README.md index f15833ea8..9731ef8da 100644 --- a/docs/eventing/samples/sequence/sequence-terminal/README.md +++ b/docs/eventing/samples/sequence/sequence-terminal/README.md @@ -6,7 +6,7 @@ type: "docs" --- We are going to create the following logical configuration. We create a -CronJobSource, feeding events to a [`Sequence`](../../../sequence.md). Sequence +CronJobSource, feeding events to a [`Sequence`](../../../flows/sequence.md). Sequence can then do either external work, or out of band create additional events. ![Logical Configuration](./sequence-terminal.png) @@ -85,13 +85,13 @@ If you are using a different type of Channel, you need to change the spec.channelTemplate to point to your desired Channel. ```yaml -apiVersion: flows.knative.dev/v1alpha1 +apiVersion: flows.knative.dev/v1beta1 kind: Sequence metadata: name: sequence spec: channelTemplate: - apiVersion: messaging.knative.dev/v1alpha1 + apiVersion: messaging.knative.dev/v1beta1 kind: InMemoryChannel steps: - ref: @@ -115,22 +115,22 @@ the resources to be created. kubectl -n default create -f ./sequence.yaml ``` -### Create the CronJobSource targeting the Sequence +### Create the PingSource targeting the Sequence -This will create a CronJobSource which will send a CloudEvent with {"message": -"Hello world!"} as the data payload every 2 minutes. +This will create a PingSource which will send a CloudEvent with `{"message": +"Hello world!"}` as the data payload every 2 minutes. ```yaml -apiVersion: sources.eventing.knative.dev/v1alpha1 -kind: CronJobSource +apiVersion: sources.knative.dev/v1alpha1 +kind: PingSource metadata: - name: cronjob-source + name: ping-source spec: schedule: "*/2 * * * *" data: '{"message": "Hello world!"}' sink: ref: - apiVersion: flows.knative.dev/v1alpha1 + apiVersion: flows.knative.dev/v1beta1 kind: Sequence name: sequence ``` @@ -139,13 +139,13 @@ Here, if you are using different type of Channel, you need to change the spec.channelTemplate to point to your desired Channel. ```shell -kubectl -n default create -f ./cron-source.yaml +kubectl -n default create -f ./ping-source.yaml ``` ### Inspecting the results You can now see the final output by inspecting the logs of the event-display -pods. Note that since we set the `CronJobSource` to emit every 2 minutes, it +pods. Note that since we set the `PingSource` to emit every 2 minutes, it might take some time for the events to show up in the logs. ```shell @@ -155,104 +155,41 @@ kubectl -n default get pods Let's look at the logs for the first `Step` in the `Sequence`: ```shell -kubectl -n default logs --tail=50 -l serving.knative.dev/service=first -c user-container -Got Event Context: Context Attributes, - specversion: 0.2 - type: dev.knative.cronjob.event - source: /apis/v1/namespaces/default/cronjobsources/cronjob-source - id: 2fdf69ec-0480-463a-92fb-8d1259550f32 - time: 2019-06-18T14:38:00.000379084Z - contenttype: application/json -Extensions, - knativehistory: sequence-kn-sequence-0-kn-channel.default.svc.cluster.local -2019/06/18 14:38:14 http: superfluous response.WriteHeader call from github.com/vaikas-google/transformer/vendor/github.com/cloudevents/sdk-go/pkg/cloudevents/transport/http.(*Transport).ServeHTTP (transport.go:446) +kubectl -n default logs -l serving.knative.dev/service=first -c user-container --tail=-1 -Got Data: &{Sequence:0 Message:Hello world!} -Got Transport Context: Transport Context, - URI: / - Host: first.default.svc.cluster.local - Method: POST - Header: - X-Request-Id: 9b51bcaa-10bc-97a5-a288-dde9b97f6e1e - Content-Length: 26 - K-Proxy-Request: activator - X-Forwarded-For: 10.16.3.77, 127.0.0.1, 127.0.0.1 - X-Forwarded-Proto: http - Ce-Knativehistory: sequence-kn-sequence-0-kn-channel.default.svc.cluster.local - X-B3-Spanid: 42bcd58bd1ea8191 - X-B3-Parentspanid: c63efd989dcf5dc5 - X-B3-Sampled: 0 - X-B3-Traceid: 4a1da6622ecbbdea0c75ae32e065cfcb - ----------------------------- +2020/03/02 21:28:00 listening on 8080, appending " - Handled by 0" to events +2020/03/02 21:28:01 Received a new event: +2020/03/02 21:28:01 [2020-03-02T21:28:00.0010247Z] /apis/v1/namespaces/default/pingsources/ping-source dev.knative.sources.ping: &{Sequence:0 Message:Hello world!} +2020/03/02 21:28:01 Transform the event to: +2020/03/02 21:28:01 [2020-03-02T21:28:00.0010247Z] /apis/v1/namespaces/default/pingsources/ping-source dev.knative.sources.ping: &{Sequence:0 Message:Hello world! - Handled by 0} ``` Then we can look at the output of the second Step in the `Sequence`: ```shell -kubectl -n default logs --tail=50 -l serving.knative.dev/service=second -c user-container -Got Event Context: Context Attributes, - cloudEventsVersion: 0.1 - eventType: samples.http.mod3 - source: /transformer/0 - eventID: 5a9ec173-5224-41a2-9c83-50786651bcd5 - eventTime: 2019-06-18T14:38:14.657008072Z - contentType: application/json +kubectl -n default logs -l serving.knative.dev/service=second -c user-container --tail=-1 -Got Data: &{Sequence:0 Message:Hello world! - Handled by 0} -Got Transport Context: Transport Context, - URI: / - Host: second.default.svc.cluster.local - Method: POST - Header: - X-Forwarded-For: 10.16.3.77, 127.0.0.1, 127.0.0.1 - X-Forwarded-Proto: http - Content-Length: 48 - X-B3-Sampled: 0 - Ce-Knativehistory: sequence-kn-sequence-1-kn-channel.default.svc.cluster.local - X-B3-Parentspanid: 4fba491a605b2391 - K-Proxy-Request: activator - X-B3-Spanid: 56e4150c4e1d679b - X-B3-Traceid: fb468aa8ec035a66153ce3f4929aa2fe - X-Request-Id: d60e7109-3853-9ca1-83e2-c70f8cbfbb93 - ----------------------------- +2020/03/02 21:28:02 listening on 8080, appending " - Handled by 1" to events +2020/03/02 21:28:02 Received a new event: +2020/03/02 21:28:02 [2020-03-02T21:28:00.0010247Z] /apis/v1/namespaces/default/pingsources/ping-source dev.knative.sources.ping: &{Sequence:0 Message:Hello world! - Handled by 0} +2020/03/02 21:28:02 Transform the event to: +2020/03/02 21:28:02 [2020-03-02T21:28:00.0010247Z] /apis/v1/namespaces/default/pingsources/ping-source dev.knative.sources.ping: &{Sequence:0 Message:Hello world! - Handled by 0 - Handled by 1} ``` -And you can see that the initial Cron Source message ("Hello World!") has now +And you can see that the initial PingSource message `("Hello World!")` has now been modified by the first step in the Sequence to include " - Handled by 0". Exciting :) Then we can look at the output of the last Step in the `Sequence`: ```shell -kubectl -n default logs --tail=50 -l serving.knative.dev/service=third -c user-container -Got Event Context: Context Attributes, - cloudEventsVersion: 0.1 - eventType: samples.http.mod3 - source: /transformer/1 - eventID: 5747fb77-66a2-4e78-944b-43192aa879fb - eventTime: 2019-06-18T14:38:32.688345694Z - contentType: application/json +kubectl -n default logs -l serving.knative.dev/service=third -c user-container --tail=-1 -Got Data: &{Sequence:0 Message:Hello world! - Handled by 0 - Handled by 1} -Got Transport Context: Transport Context, - URI: / - Host: third.default.svc.cluster.local - Method: POST - Header: - X-B3-Sampled: 0 - X-B3-Traceid: 64a9c48c219375476ffcdd5eb14ec6e0 - X-Forwarded-For: 10.16.3.77, 127.0.0.1, 127.0.0.1 - X-Forwarded-Proto: http - Ce-Knativehistory: sequence-kn-sequence-2-kn-channel.default.svc.cluster.local - K-Proxy-Request: activator - X-Request-Id: 505ff620-2822-9e7d-8855-53d02a2e36e2 - Content-Length: 63 - X-B3-Parentspanid: 9e822f378ead293c - X-B3-Spanid: a56ee81909c767e6 - ----------------------------- +2020/03/02 21:28:03 listening on 8080, appending " - Handled by 2" to events +2020/03/02 21:28:03 Received a new event: +2020/03/02 21:28:03 [2020-03-02T21:28:00.0010247Z] /apis/v1/namespaces/default/pingsources/ping-source dev.knative.sources.ping: &{Sequence:0 Message:Hello world! - Handled by 0 - Handled by 1} +2020/03/02 21:28:03 Transform the event to: +2020/03/02 21:28:03 [2020-03-02T21:28:00.0010247Z] /apis/v1/namespaces/default/pingsources/ping-source dev.knative.sources.ping: &{Sequence:0 Message:Hello world! - Handled by 0 - Handled by 1 - Handled by 2} ``` And as expected it's now been handled by both the first and second Step as diff --git a/docs/eventing/samples/sequence/sequence-terminal/cron-source.yaml b/docs/eventing/samples/sequence/sequence-terminal/ping-source.yaml similarity index 50% rename from docs/eventing/samples/sequence/sequence-terminal/cron-source.yaml rename to docs/eventing/samples/sequence/sequence-terminal/ping-source.yaml index 3a68fe4c4..fbe88b4cc 100644 --- a/docs/eventing/samples/sequence/sequence-terminal/cron-source.yaml +++ b/docs/eventing/samples/sequence/sequence-terminal/ping-source.yaml @@ -1,12 +1,12 @@ -apiVersion: sources.eventing.knative.dev/v1alpha1 -kind: CronJobSource +apiVersion: sources.knative.dev/v1alpha1 +kind: PingSource metadata: - name: cronjob-source + name: ping-source spec: schedule: "*/2 * * * *" data: '{"message": "Hello world!"}' sink: ref: - apiVersion: flows.knative.dev/v1alpha1 + apiVersion: flows.knative.dev/v1beta1 kind: Sequence name: sequence diff --git a/docs/eventing/samples/sequence/sequence-terminal/sequence-terminal.png b/docs/eventing/samples/sequence/sequence-terminal/sequence-terminal.png index 5cb9d5264..7210151b7 100644 Binary files a/docs/eventing/samples/sequence/sequence-terminal/sequence-terminal.png and b/docs/eventing/samples/sequence/sequence-terminal/sequence-terminal.png differ diff --git a/docs/eventing/samples/sequence/sequence-terminal/sequence.yaml b/docs/eventing/samples/sequence/sequence-terminal/sequence.yaml index 8241bade3..22c26bad8 100644 --- a/docs/eventing/samples/sequence/sequence-terminal/sequence.yaml +++ b/docs/eventing/samples/sequence/sequence-terminal/sequence.yaml @@ -1,10 +1,10 @@ -apiVersion: flows.knative.dev/v1alpha1 +apiVersion: flows.knative.dev/v1beta1 kind: Sequence metadata: name: sequence spec: channelTemplate: - apiVersion: messaging.knative.dev/v1alpha1 + apiVersion: messaging.knative.dev/v1beta1 kind: InMemoryChannel steps: - ref: diff --git a/docs/eventing/samples/sequence/sequence-with-broker-trigger/README.md b/docs/eventing/samples/sequence/sequence-with-broker-trigger/README.md index 239a52018..5773d06c7 100644 --- a/docs/eventing/samples/sequence/sequence-with-broker-trigger/README.md +++ b/docs/eventing/samples/sequence/sequence-with-broker-trigger/README.md @@ -6,15 +6,14 @@ type: "docs" --- We are going to create the following logical configuration. We create a -CronJobSource, feeding events into the Broker, then we create a `Filter` that -wires those events into a [`Sequence`](../../../sequence.md) consisting of 3 +PingSource, feeding events into the Broker, then we create a `Filter` that +wires those events into a [`Sequence`](../../../flows/sequence.md) consisting of 3 steps. Then we take the end of the Sequence and feed newly minted events back into the Broker and create another Trigger which will then display those events. ## Prerequisites -For this example, we'll assume you have set up a `Broker` and an -`InMemoryChannel` as well as Knative Serving (for our functions). The examples +For this example, we'll assume you have set up an `InMemoryChannel` as well as Knative Serving (for our functions). The examples use `default` namespace, again, if your broker lives in another Namespace, you will need to modify the examples to reflect this. @@ -28,6 +27,14 @@ The functions used in these examples live in ## Setup +### Creating the Broker + +The easiest way to create a Broker is to annotate your namespace: + +```shell +kubectl label namespace default knative-eventing-injection=enabled +``` + ### Create the Knative Services Change `default` below to create the steps in the Namespace where you have @@ -91,13 +98,13 @@ spec.channelTemplate to point to your desired Channel. Also, change the spec.reply.name to point to your `Broker` ```yaml -apiVersion: flows.knative.dev/v1alpha1 +apiVersion: flows.knative.dev/v1beta1 kind: Sequence metadata: name: sequence spec: channelTemplate: - apiVersion: messaging.knative.dev/v1alpha1 + apiVersion: messaging.knative.dev/v1beta1 kind: InMemoryChannel steps: - ref: @@ -115,7 +122,7 @@ spec: reply: ref: kind: Broker - apiVersion: eventing.knative.dev/v1alpha1 + apiVersion: eventing.knative.dev/v1beta1 name: default ``` @@ -126,22 +133,22 @@ configured your `Broker`. kubectl -n default create -f ./sequence.yaml ``` -### Create the CronJobSource targeting the Broker +### Create the PingSource targeting the Broker -This will create a CronJobSource which will send a CloudEvent with {"message": +This will create a PingSource which will send a CloudEvent with {"message": "Hello world!"} as the data payload every 2 minutes. ```yaml -apiVersion: sources.eventing.knative.dev/v1alpha1 -kind: CronJobSource +apiVersion: sources.knative.dev/v1alpha1 +kind: PingSource metadata: - name: cronjob-source + name: ping-source spec: schedule: "*/2 * * * *" data: '{"message": "Hello world!"}' sink: ref: - apiVersion: eventing.knative.dev/v1alpha1 + apiVersion: eventing.knative.dev/v1beta1 kind: Broker name: default ``` @@ -154,23 +161,23 @@ Change `default` below to create the `Sequence` in the Namespace where you have configured your `Broker`. ```shell -kubectl -n default create -f ./cron-source.yaml +kubectl -n default create -f ./ping-source.yaml ``` ### Create the Trigger targeting the Sequence ```yaml -apiVersion: eventing.knative.dev/v1alpha1 +apiVersion: eventing.knative.dev/v1beta1 kind: Trigger metadata: name: sequence-trigger spec: filter: attributes: - type: dev.knative.cronjob.event + type: dev.knative.sources.ping subscriber: ref: - apiVersion: flows.knative.dev/v1alpha1 + apiVersion: flows.knative.dev/v1beta1 kind: Sequence name: sequence ``` @@ -232,16 +239,20 @@ kubectl -n default get pods Then look at the logs for the event-display pod: ```shell -kubectl -n default logs --tail=50 -l serving.knative.dev/service=sequence-display -c user-container +kubectl -n default logs -l serving.knative.dev/service=sequence-display -c user-container --tail=-1 ☁️ cloudevents.Event Validation: valid Context Attributes, - cloudEventsVersion: 0.1 - eventType: samples.http.mod3 - source: /transformer/2 - eventID: df52b47e-02fd-45b2-8180-dabb572573f5 - eventTime: 2019-06-18T14:18:42.478140635Z - contentType: application/json + specversion: 1.0 + type: samples.http.mod3 + source: /apis/v1/namespaces/default/pingsources/ping-source + id: 159bba01-054a-4ae7-b7be-d4e7c5f773d2 + time: 2020-03-03T14:56:00.000652027Z + datacontenttype: application/json +Extensions, + knativearrivaltime: 2020-03-03T14:56:00.018390608Z + knativehistory: default-kne-trigger-kn-channel.default.svc.cluster.local; sequence-kn-sequence-0-kn-channel.default.svc.cluster.local; sequence-kn-sequence-1-kn-channel.default.svc.cluster.local; sequence-kn-sequence-2-kn-channel.default.svc.cluster.local; default-kne-trigger-kn-channel.default.svc.cluster.local + traceparent: 00-e893412106ff417a90a5695e53ffd9cc-5829ae45a14ed462-00 Data, { "id": 0, @@ -249,5 +260,5 @@ Data, } ``` -And you can see that the initial Cron Source message ("Hello World!") has been +And you can see that the initial PingSource message `{"Hello World!"}` has been appended to it by each of the steps in the Sequence. diff --git a/docs/eventing/samples/sequence/sequence-with-broker-trigger/cron-source.yaml b/docs/eventing/samples/sequence/sequence-with-broker-trigger/cron-source.yaml deleted file mode 100644 index 71a3a1b8b..000000000 --- a/docs/eventing/samples/sequence/sequence-with-broker-trigger/cron-source.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: sources.eventing.knative.dev/v1alpha1 -kind: CronJobSource -metadata: - name: cronjob-source -spec: - schedule: "*/2 * * * *" - data: '{"message": "Hello world!"}' - sink: - ref: - apiVersion: eventing.knative.dev/v1alpha1 - kind: Broker - name: default diff --git a/docs/eventing/samples/sequence/sequence-with-broker-trigger/display-trigger.yaml b/docs/eventing/samples/sequence/sequence-with-broker-trigger/display-trigger.yaml index baa2bc703..febdc24ce 100644 --- a/docs/eventing/samples/sequence/sequence-with-broker-trigger/display-trigger.yaml +++ b/docs/eventing/samples/sequence/sequence-with-broker-trigger/display-trigger.yaml @@ -6,9 +6,9 @@ spec: template: spec: containers: - - image: gcr.io/knative-releases/knative.dev/eventing-sources/cmd/event_display + - image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display --- -apiVersion: eventing.knative.dev/v1alpha1 +apiVersion: eventing.knative.dev/v1beta1 kind: Trigger metadata: name: display-trigger diff --git a/docs/eventing/samples/sequence/sequence-with-broker-trigger/ping-source.yaml b/docs/eventing/samples/sequence/sequence-with-broker-trigger/ping-source.yaml new file mode 100644 index 000000000..3207e8c27 --- /dev/null +++ b/docs/eventing/samples/sequence/sequence-with-broker-trigger/ping-source.yaml @@ -0,0 +1,12 @@ +apiVersion: sources.knative.dev/v1alpha1 +kind: PingSource +metadata: + name: ping-source +spec: + schedule: "*/2 * * * *" + data: '{"message": "Hello world!"}' + sink: + ref: + apiVersion: eventing.knative.dev/v1beta1 + kind: Broker + name: default diff --git a/docs/eventing/samples/sequence/sequence-with-broker-trigger/sequence-with-broker-trigger.png b/docs/eventing/samples/sequence/sequence-with-broker-trigger/sequence-with-broker-trigger.png index 756cfdaa2..a4936c329 100644 Binary files a/docs/eventing/samples/sequence/sequence-with-broker-trigger/sequence-with-broker-trigger.png and b/docs/eventing/samples/sequence/sequence-with-broker-trigger/sequence-with-broker-trigger.png differ diff --git a/docs/eventing/samples/sequence/sequence-with-broker-trigger/sequence.yaml b/docs/eventing/samples/sequence/sequence-with-broker-trigger/sequence.yaml index 8e375c769..3b1e2318e 100644 --- a/docs/eventing/samples/sequence/sequence-with-broker-trigger/sequence.yaml +++ b/docs/eventing/samples/sequence/sequence-with-broker-trigger/sequence.yaml @@ -1,10 +1,10 @@ -apiVersion: flows.knative.dev/v1alpha1 +apiVersion: flows.knative.dev/v1beta1 kind: Sequence metadata: name: sequence spec: channelTemplate: - apiVersion: messaging.knative.dev/v1alpha1 + apiVersion: messaging.knative.dev/v1beta1 kind: InMemoryChannel steps: - ref: @@ -22,5 +22,5 @@ spec: reply: ref: kind: Broker - apiVersion: eventing.knative.dev/v1alpha1 + apiVersion: eventing.knative.dev/v1beta1 name: default diff --git a/docs/eventing/samples/sequence/sequence-with-broker-trigger/steps.yaml b/docs/eventing/samples/sequence/sequence-with-broker-trigger/steps.yaml index a35c511e2..013b8b98a 100644 --- a/docs/eventing/samples/sequence/sequence-with-broker-trigger/steps.yaml +++ b/docs/eventing/samples/sequence/sequence-with-broker-trigger/steps.yaml @@ -33,9 +33,10 @@ spec: template: spec: containers: - - image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/appender env: - name: MESSAGE value: " - Handled by 2" + - name: TYPE + value: "samples.http.mod3" --- diff --git a/docs/eventing/samples/sequence/sequence-with-broker-trigger/trigger.yaml b/docs/eventing/samples/sequence/sequence-with-broker-trigger/trigger.yaml index 664f1587e..6ad911d36 100644 --- a/docs/eventing/samples/sequence/sequence-with-broker-trigger/trigger.yaml +++ b/docs/eventing/samples/sequence/sequence-with-broker-trigger/trigger.yaml @@ -1,4 +1,4 @@ -apiVersion: eventing.knative.dev/v1alpha1 +apiVersion: eventing.knative.dev/v1beta1 kind: Trigger metadata: name: sequence-trigger @@ -6,9 +6,9 @@ spec: broker: default filter: attributes: - type: dev.knative.cronjob.event + type: dev.knative.sources.ping subscriber: ref: - apiVersion: flows.knative.dev/v1alpha1 + apiVersion: flows.knative.dev/v1beta1 kind: Sequence name: sequence