From 9a04cb676153c31876ba70ac12a3f0095d6e897b Mon Sep 17 00:00:00 2001 From: Scott Nichols Date: Thu, 27 Feb 2020 07:32:03 -0800 Subject: [PATCH 1/6] Document ping source. --- docs/eventing/samples/ping-source/README.md | 153 ++++++++++++++++++ .../samples/ping-source/ping-source.yaml | 12 ++ .../eventing/samples/ping-source/service.yaml | 11 ++ 3 files changed, 176 insertions(+) create mode 100644 docs/eventing/samples/ping-source/README.md create mode 100644 docs/eventing/samples/ping-source/ping-source.yaml create mode 100644 docs/eventing/samples/ping-source/service.yaml diff --git a/docs/eventing/samples/ping-source/README.md b/docs/eventing/samples/ping-source/README.md new file mode 100644 index 00000000000..1663fbce5ce --- /dev/null +++ b/docs/eventing/samples/ping-source/README.md @@ -0,0 +1,153 @@ +--- +title: "PingSource example" +linkTitle: "PingSource" +weight: 10 +type: "docs" +--- + +This example shows how to configure PingSource as an event source for +functions. + +## Before you begin + +1. Set up [Knative Serving](../../../serving). +1. Set up [Knative Eventing](../../../eventing). + +## Create a Knative Service + +To verify that `PingSource` is working, create a simple Knative +Service that dumps incoming messages to its log. + +{{< tabs name="create-service" default="By YAML" >}} +{{% tab name="By YAML" %}} +Use following command to create the service from STDIN: + +```shell +cat <}} + +{{% tab name="By filename" %}} +Use following command to create the service from the `service.yaml` file: + +```shell +kubectl apply --filename service.yaml +``` +{{< /tab >}} +{{< /tabs >}} + +## Create a PingSource + +For each set of ping events that you want to request, create an Event +Source in the same namespace as the destination. + +{{< tabs name="create-source" default="By YAML" >}} +{{% tab name="By YAML" %}} +Use following command to create the event source from STDIN: + +```shell +cat <}} + +{{% tab name="By filename" %}} +Use following command to create the event source from the `ping-source.yaml` file: + +```shell +kubectl apply --filename ping-source.yaml +``` +{{< /tab >}} +{{< /tabs >}} + + +## Verify + +Verify that the message was sent to the Knative eventing system by +looking at message dumper logs. + +```shell +kubectl logs -l serving.knative.dev/service=event-display -c user-container --since=10m +``` + +You should see log lines showing the request headers and body from the source: + +``` +☁️ cloudevents.Event +Validation: valid +Context Attributes, + specversion: 1.0 + type: dev.knative.sources.ping + source: /apis/v1/namespaces/default/cronjobsources/test-cronjob-source + id: d8e761eb-30c7-49a3-a421-cd5895239f2d + time: 2019-12-04T14:24:00.000702251Z + datacontenttype: application/json +Data, + { + "message": "Hello world!" + } +``` + +You can also use [`kail`](https://github.com/boz/kail) instead of `kubectl logs` +to tail the logs of the subscriber. + +```shell +kail -l serving.knative.dev/service=event-display -c user-container --since=10m +``` + +## Cleanup + +You can delete the PingSource instance by entering the following command: + +{{< tabs name="delete-source" default="By filename" >}} +{{% tab name="By filename" %}} +```shell +kubectl delete --filename ping-source.yaml +``` +{{< /tab >}} + +{{% tab name="By name" %}} +```shell +kubectl delete pingsources.sources.knative.dev test-ping-source +``` +{{< /tab >}} +{{< /tabs >}} + + +Similarly, you can delete the Service instance via: + +{{< tabs name="delete-service" default="By filename" >}} +{{% tab name="By filename" %}} +```shell +kubectl delete --filename service.yaml +``` +{{< /tab >}} + +{{% tab name="By name" %}} +```shell +kubectl delete service.serving.knative.dev event-display +``` +{{< /tab >}} +{{< /tabs >}} diff --git a/docs/eventing/samples/ping-source/ping-source.yaml b/docs/eventing/samples/ping-source/ping-source.yaml new file mode 100644 index 00000000000..12b0cecfbc9 --- /dev/null +++ b/docs/eventing/samples/ping-source/ping-source.yaml @@ -0,0 +1,12 @@ +apiVersion: sources.knative.dev/v1alpha1 +kind: PingSource +metadata: + name: test-ping-source +spec: + schedule: "*/2 * * * *" + data: '{"message": "Hello world!"}' + sink: + ref: + apiVersion: serving.knative.dev/v1 + kind: Service + name: event-display diff --git a/docs/eventing/samples/ping-source/service.yaml b/docs/eventing/samples/ping-source/service.yaml new file mode 100644 index 00000000000..c3937eaf630 --- /dev/null +++ b/docs/eventing/samples/ping-source/service.yaml @@ -0,0 +1,11 @@ +# This is a very simple Knative Service that writes the input request to its log. + +apiVersion: serving.knative.dev/v1 +kind: Service +metadata: + name: event-display +spec: + template: + spec: + containers: + - image: gcr.io/knative-releases/github.com/knative/eventing-contrib/cmd/event_display From df1f129566778051ed7fe7b6455e9bc7f5e49c70 Mon Sep 17 00:00:00 2001 From: Scott Nichols Date: Thu, 27 Feb 2020 07:38:36 -0800 Subject: [PATCH 2/6] Squashed commit of the following: commit 9a04cb676153c31876ba70ac12a3f0095d6e897b Author: Scott Nichols Date: Thu Feb 27 07:32:03 2020 -0800 Document ping source. --- docs/eventing/samples/ping-source/README.md | 153 ++++++++++++++++++ .../samples/ping-source/ping-source.yaml | 12 ++ .../eventing/samples/ping-source/service.yaml | 11 ++ 3 files changed, 176 insertions(+) create mode 100644 docs/eventing/samples/ping-source/README.md create mode 100644 docs/eventing/samples/ping-source/ping-source.yaml create mode 100644 docs/eventing/samples/ping-source/service.yaml diff --git a/docs/eventing/samples/ping-source/README.md b/docs/eventing/samples/ping-source/README.md new file mode 100644 index 00000000000..1663fbce5ce --- /dev/null +++ b/docs/eventing/samples/ping-source/README.md @@ -0,0 +1,153 @@ +--- +title: "PingSource example" +linkTitle: "PingSource" +weight: 10 +type: "docs" +--- + +This example shows how to configure PingSource as an event source for +functions. + +## Before you begin + +1. Set up [Knative Serving](../../../serving). +1. Set up [Knative Eventing](../../../eventing). + +## Create a Knative Service + +To verify that `PingSource` is working, create a simple Knative +Service that dumps incoming messages to its log. + +{{< tabs name="create-service" default="By YAML" >}} +{{% tab name="By YAML" %}} +Use following command to create the service from STDIN: + +```shell +cat <}} + +{{% tab name="By filename" %}} +Use following command to create the service from the `service.yaml` file: + +```shell +kubectl apply --filename service.yaml +``` +{{< /tab >}} +{{< /tabs >}} + +## Create a PingSource + +For each set of ping events that you want to request, create an Event +Source in the same namespace as the destination. + +{{< tabs name="create-source" default="By YAML" >}} +{{% tab name="By YAML" %}} +Use following command to create the event source from STDIN: + +```shell +cat <}} + +{{% tab name="By filename" %}} +Use following command to create the event source from the `ping-source.yaml` file: + +```shell +kubectl apply --filename ping-source.yaml +``` +{{< /tab >}} +{{< /tabs >}} + + +## Verify + +Verify that the message was sent to the Knative eventing system by +looking at message dumper logs. + +```shell +kubectl logs -l serving.knative.dev/service=event-display -c user-container --since=10m +``` + +You should see log lines showing the request headers and body from the source: + +``` +☁️ cloudevents.Event +Validation: valid +Context Attributes, + specversion: 1.0 + type: dev.knative.sources.ping + source: /apis/v1/namespaces/default/cronjobsources/test-cronjob-source + id: d8e761eb-30c7-49a3-a421-cd5895239f2d + time: 2019-12-04T14:24:00.000702251Z + datacontenttype: application/json +Data, + { + "message": "Hello world!" + } +``` + +You can also use [`kail`](https://github.com/boz/kail) instead of `kubectl logs` +to tail the logs of the subscriber. + +```shell +kail -l serving.knative.dev/service=event-display -c user-container --since=10m +``` + +## Cleanup + +You can delete the PingSource instance by entering the following command: + +{{< tabs name="delete-source" default="By filename" >}} +{{% tab name="By filename" %}} +```shell +kubectl delete --filename ping-source.yaml +``` +{{< /tab >}} + +{{% tab name="By name" %}} +```shell +kubectl delete pingsources.sources.knative.dev test-ping-source +``` +{{< /tab >}} +{{< /tabs >}} + + +Similarly, you can delete the Service instance via: + +{{< tabs name="delete-service" default="By filename" >}} +{{% tab name="By filename" %}} +```shell +kubectl delete --filename service.yaml +``` +{{< /tab >}} + +{{% tab name="By name" %}} +```shell +kubectl delete service.serving.knative.dev event-display +``` +{{< /tab >}} +{{< /tabs >}} diff --git a/docs/eventing/samples/ping-source/ping-source.yaml b/docs/eventing/samples/ping-source/ping-source.yaml new file mode 100644 index 00000000000..12b0cecfbc9 --- /dev/null +++ b/docs/eventing/samples/ping-source/ping-source.yaml @@ -0,0 +1,12 @@ +apiVersion: sources.knative.dev/v1alpha1 +kind: PingSource +metadata: + name: test-ping-source +spec: + schedule: "*/2 * * * *" + data: '{"message": "Hello world!"}' + sink: + ref: + apiVersion: serving.knative.dev/v1 + kind: Service + name: event-display diff --git a/docs/eventing/samples/ping-source/service.yaml b/docs/eventing/samples/ping-source/service.yaml new file mode 100644 index 00000000000..c3937eaf630 --- /dev/null +++ b/docs/eventing/samples/ping-source/service.yaml @@ -0,0 +1,11 @@ +# This is a very simple Knative Service that writes the input request to its log. + +apiVersion: serving.knative.dev/v1 +kind: Service +metadata: + name: event-display +spec: + template: + spec: + containers: + - image: gcr.io/knative-releases/github.com/knative/eventing-contrib/cmd/event_display From c5aa0699bb50f8f8cacc0a09db4ae9a4abf4b873 Mon Sep 17 00:00:00 2001 From: Scott Nichols Date: Thu, 27 Feb 2020 10:56:11 -0800 Subject: [PATCH 3/6] typo on source. --- docs/eventing/samples/ping-source/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/eventing/samples/ping-source/README.md b/docs/eventing/samples/ping-source/README.md index 1663fbce5ce..39a947f779d 100644 --- a/docs/eventing/samples/ping-source/README.md +++ b/docs/eventing/samples/ping-source/README.md @@ -100,7 +100,7 @@ Validation: valid Context Attributes, specversion: 1.0 type: dev.knative.sources.ping - source: /apis/v1/namespaces/default/cronjobsources/test-cronjob-source + source: /apis/v1/namespaces/default/pingsources/test-ping-source id: d8e761eb-30c7-49a3-a421-cd5895239f2d time: 2019-12-04T14:24:00.000702251Z datacontenttype: application/json From 485eea022787a176b6b52678e37548cb73980431 Mon Sep 17 00:00:00 2001 From: Scott Nichols Date: Thu, 27 Feb 2020 10:59:29 -0800 Subject: [PATCH 4/6] update image --- docs/eventing/samples/ping-source/README.md | 2 +- docs/eventing/samples/ping-source/service.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/eventing/samples/ping-source/README.md b/docs/eventing/samples/ping-source/README.md index 39a947f779d..0a5b67ecb52 100644 --- a/docs/eventing/samples/ping-source/README.md +++ b/docs/eventing/samples/ping-source/README.md @@ -32,7 +32,7 @@ spec: template: spec: containers: - - image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/event_display + - image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display EOF ``` {{< /tab >}} diff --git a/docs/eventing/samples/ping-source/service.yaml b/docs/eventing/samples/ping-source/service.yaml index c3937eaf630..38ac01bc0ff 100644 --- a/docs/eventing/samples/ping-source/service.yaml +++ b/docs/eventing/samples/ping-source/service.yaml @@ -8,4 +8,4 @@ spec: template: spec: containers: - - image: gcr.io/knative-releases/github.com/knative/eventing-contrib/cmd/event_display + - image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display From 1e2f73427e4613df242faf44eb813cae5af9019a Mon Sep 17 00:00:00 2001 From: Scott Nichols Date: Thu, 27 Feb 2020 11:04:42 -0800 Subject: [PATCH 5/6] kail tabs --- docs/eventing/samples/ping-source/README.md | 25 +++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/eventing/samples/ping-source/README.md b/docs/eventing/samples/ping-source/README.md index 0a5b67ecb52..b8ed1fdc609 100644 --- a/docs/eventing/samples/ping-source/README.md +++ b/docs/eventing/samples/ping-source/README.md @@ -88,10 +88,28 @@ kubectl apply --filename ping-source.yaml Verify that the message was sent to the Knative eventing system by looking at message dumper logs. +{{< tabs name="view-event" default="kubectl" >}} +{{% tab name="kubectl" %}} + +Use following command to view the logs of the event-display service: + ```shell kubectl logs -l serving.knative.dev/service=event-display -c user-container --since=10m ``` +{{< /tab >}} +{{% tab name="kail" %}} + +You can also use [`kail`](https://github.com/boz/kail) instead of `kubectl logs` +to tail the logs of the subscriber. + +```shell +kail -l serving.knative.dev/service=event-display -c user-container --since=10m +``` + +{{< /tab >}} +{{< /tabs >}} + You should see log lines showing the request headers and body from the source: ``` @@ -110,13 +128,6 @@ Data, } ``` -You can also use [`kail`](https://github.com/boz/kail) instead of `kubectl logs` -to tail the logs of the subscriber. - -```shell -kail -l serving.knative.dev/service=event-display -c user-container --since=10m -``` - ## Cleanup You can delete the PingSource instance by entering the following command: From a1e2c7a5aac80df93bb30890dfe7a7b408b6b4f0 Mon Sep 17 00:00:00 2001 From: Scott Nichols Date: Thu, 27 Feb 2020 16:17:26 -0800 Subject: [PATCH 6/6] by name default --- docs/eventing/samples/ping-source/README.md | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/eventing/samples/ping-source/README.md b/docs/eventing/samples/ping-source/README.md index b8ed1fdc609..2f4cabca09d 100644 --- a/docs/eventing/samples/ping-source/README.md +++ b/docs/eventing/samples/ping-source/README.md @@ -132,16 +132,16 @@ Data, You can delete the PingSource instance by entering the following command: -{{< tabs name="delete-source" default="By filename" >}} -{{% tab name="By filename" %}} +{{< tabs name="delete-source" default="By name" >}} +{{% tab name="By name" %}} ```shell -kubectl delete --filename ping-source.yaml +kubectl delete pingsources.sources.knative.dev test-ping-source ``` {{< /tab >}} -{{% tab name="By name" %}} +{{% tab name="By filename" %}} ```shell -kubectl delete pingsources.sources.knative.dev test-ping-source +kubectl delete --filename ping-source.yaml ``` {{< /tab >}} {{< /tabs >}} @@ -149,16 +149,16 @@ kubectl delete pingsources.sources.knative.dev test-ping-source Similarly, you can delete the Service instance via: -{{< tabs name="delete-service" default="By filename" >}} -{{% tab name="By filename" %}} +{{< tabs name="delete-service" default="By name" >}} +{{% tab name="By name" %}} ```shell -kubectl delete --filename service.yaml +kubectl delete service.serving.knative.dev event-display ``` {{< /tab >}} - -{{% tab name="By name" %}} +{{% tab name="By filename" %}} ```shell -kubectl delete service.serving.knative.dev event-display +kubectl delete --filename service.yaml ``` {{< /tab >}} + {{< /tabs >}}