Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -175,25 +175,28 @@ 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,
"message": "Hello world! - Handled by 0 - Handled by 1 - Handled by 2"
}
```

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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: sources.eventing.knative.dev/v1alpha1
kind: CronJobSource
apiVersion: sources.knative.dev/v1alpha1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, could also change these to v1alpha2?

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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ spec:
env:
- name: MESSAGE
value: " - Handled by 2"
- name: TYPE
value: "samples.http.mod3"
---
56 changes: 32 additions & 24 deletions docs/eventing/samples/sequence/sequence-reply-to-sequence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -254,22 +259,25 @@ 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,
"message": "Hello world! - Handled by 0 - Handled by 1 - Handled by 2 - Handled by 3 - Handled by 4 - Handled by 5"
}
```

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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -22,5 +22,5 @@ spec:
reply:
ref:
kind: Sequence
apiVersion: flows.knative.dev/v1alpha1
apiVersion: flows.knative.dev/v1beta1
name: second-sequence
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Loading