From fbdda6532e0c6eb14e9e0cc7e8a771240fb70034 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Wed, 27 Mar 2019 13:19:31 -0700 Subject: [PATCH 1/2] Update the iot-core demo to use Broker rather than Channel. Also remove ko and kail usage. --- docs/eventing/samples/iot-core/README.md | 54 ++++++++----------- docs/eventing/samples/iot-core/channel.yaml | 10 ---- .../samples/iot-core/gcp-pubsub-source.yaml | 6 +-- .../{subscription.yaml => trigger.yaml} | 10 ++-- 4 files changed, 30 insertions(+), 50 deletions(-) delete mode 100644 docs/eventing/samples/iot-core/channel.yaml rename docs/eventing/samples/iot-core/{subscription.yaml => trigger.yaml} (61%) diff --git a/docs/eventing/samples/iot-core/README.md b/docs/eventing/samples/iot-core/README.md index b6eee722ce1..07574912c92 100644 --- a/docs/eventing/samples/iot-core/README.md +++ b/docs/eventing/samples/iot-core/README.md @@ -24,7 +24,6 @@ export IOTCORE_PROJECT="s9-demo" #### Variables you may Change ```shell -export CHANNEL_NAME="iot-demo" export IOTCORE_REGISTRY="iot-demo" export IOTCORE_DEVICE="iot-demo-client" export IOTCORE_REGION="us-central1" @@ -67,13 +66,6 @@ export IOTCORE_TOPIC_DEVICE="iot-demo-device-pubsub-topic" 1. Setup [Knative Eventing](../../../eventing). -1. Install the - [in-memory `ClusterChannelProvisioner`](https://github.com/knative/eventing/tree/master/config/provisioners/in-memory-channel). - - - Note that you can skip this if you choose to use a different type of - `Channel`. If so, you will need to modify `channel.yaml` before deploying - it. - #### GCP PubSub Source 1. Create a GCP @@ -94,20 +86,17 @@ export IOTCORE_TOPIC_DEVICE="iot-demo-device-pubsub-topic" controller. ```shell - pushd $HOME/go/src/github.com/knative/eventing-sources - ko apply --filename config/default-gcppubsub.yaml - popd + kubectl apply --filename https://github.com/knative/eventing-sources/releases/download/v0.5.0/gcppubsub.yaml ``` ### Deploying -#### Channel +#### Broker -1. Create a `Channel`. +1. Install the default `Broker`. ```shell - sed "s/CHANNEL_NAME/$CHANNEL_NAME/" channel.yaml | - kubectl --namespace default apply --filename - + kubectl label namespace default knative-eventing-injection=enabled ``` #### GCP PubSub Source @@ -115,23 +104,21 @@ export IOTCORE_TOPIC_DEVICE="iot-demo-device-pubsub-topic" 1. Deploy `gcp-pubsub-source.yaml`. ```shell - sed -e "s/MY_GCP_PROJECT/$IOTCORE_PROJECT/" \ + sed -e "s/PROJECT_ID/$IOTCORE_PROJECT/" \ -e "s/TOPIC_NAME/$IOTCORE_TOPIC_DATA/" \ - -e "s/CHANNEL_NAME/$CHANNEL_NAME/" \ - gcp-pubsub-source.yaml | + docs/eventing/samples/iot-core/gcp-pubsub-source.yaml | kubectl apply --filename - ``` -#### Subscription +#### Trigger Even though the `Source` isn't completely ready yet, we can setup the -`Subscription` for all events coming out of it. +`Trigger` for all events coming out of it. -1. Deploy `subscription.yaml`. +1. Deploy `trigger.yaml`. ```shell - sed "s/CHANNEL_NAME/$CHANNEL_NAME/" subscription.yaml | - ko apply --filename - + kubectl apply --filename docs/eventing/samples/iot-core/trigger.yaml ``` - This uses a very simple Knative Service to see that events are flowing. @@ -178,14 +165,7 @@ Core. We now have everything installed and ready to go. We will generate events and see them in the subscriber. -1. Setup [`kail`](https://github.com/boz/kail) to tail the logs of the - subscriber. - - ```shell - kail -d message-dumper -c user-container - ``` - -1. In a separate terminal, run the following program to generate events. +1. Run the following program to generate events. ```shell go run github.com/knative/docs/docs/eventing/samples/iot-core/generator \ @@ -198,3 +178,15 @@ see them in the subscriber. -src "iot-core demo" \ -events 10 ``` + +1. Inspect the logs of the subscriber: + + ```shell + kubectl logs --selector serving.knative.dev/service=message-dumper -c user-container + ``` + + You should see something along the similar to: + + ```shell + {"ID":"481014114648052","Data":"eyJzb3VyY2VfaWQiOiJpb3QtY29yZSBkZW1vIiwiZXZlbnRfaWQiOiJlaWQtMzI3MjJiMzItZWU5Mi00YzZlLWEzOTgtNDlmYjRkYWYyNGE1IiwiZXZlbnRfdHMiOjE1NTM3MTczOTYsIm1ldHJpYyI6MC4xMzY1MjI5OH0=","Attributes":{"deviceId":"iot-demo-client","deviceNumId":"2754785852315736","deviceRegistryId":"iot-demo","deviceRegistryLocation":"us-central1","projectId":"s9-demo","subFolder":""},"PublishTime":"2019-03-27T20:09:56.685Z"} + ``` diff --git a/docs/eventing/samples/iot-core/channel.yaml b/docs/eventing/samples/iot-core/channel.yaml deleted file mode 100644 index 75a9b14c96a..00000000000 --- a/docs/eventing/samples/iot-core/channel.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: eventing.knative.dev/v1alpha1 -kind: Channel -metadata: - name: CHANNEL_NAME - namespace: default -spec: - provisioner: - apiVersion: eventing.knative.dev/v1alpha1 - kind: ClusterChannelProvisioner - name: in-memory-channel diff --git a/docs/eventing/samples/iot-core/gcp-pubsub-source.yaml b/docs/eventing/samples/iot-core/gcp-pubsub-source.yaml index 34d0de5c99b..7d16f196dde 100644 --- a/docs/eventing/samples/iot-core/gcp-pubsub-source.yaml +++ b/docs/eventing/samples/iot-core/gcp-pubsub-source.yaml @@ -10,9 +10,9 @@ spec: gcpCredsSecret: name: google-cloud-key key: key.json - googleCloudProject: MY_GCP_PROJECT + googleCloudProject: PROJECT_ID topic: TOPIC_NAME sink: apiVersion: eventing.knative.dev/v1alpha1 - kind: Channel - name: CHANNEL_NAME + kind: Broker + name: default diff --git a/docs/eventing/samples/iot-core/subscription.yaml b/docs/eventing/samples/iot-core/trigger.yaml similarity index 61% rename from docs/eventing/samples/iot-core/subscription.yaml rename to docs/eventing/samples/iot-core/trigger.yaml index 6d9969e2bb3..c55debc7bf8 100644 --- a/docs/eventing/samples/iot-core/subscription.yaml +++ b/docs/eventing/samples/iot-core/trigger.yaml @@ -1,13 +1,9 @@ apiVersion: eventing.knative.dev/v1alpha1 -kind: Subscription +kind: Trigger metadata: name: iot-demo namespace: default spec: - channel: - apiVersion: eventing.knative.dev/v1alpha1 - kind: Channel - name: CHANNEL_NAME subscriber: ref: apiVersion: serving.knative.dev/v1alpha1 @@ -28,4 +24,6 @@ spec: revisionTemplate: spec: container: - image: github.com/knative/eventing-sources/cmd/message_dumper + # This corresponds to + # https://github.com/knative/eventing-sources/blob/release-0.3/cmd/message_dumper/dumper.go + image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/message_dumper@sha256:8423232db7a7b4010c0cfbfaef95745efe962631af9b7456903825801a7893f7 From bc946f05e50fefcb108cd260fb3f1017a5ca5fd4 Mon Sep 17 00:00:00 2001 From: Sam O'Dell <31352624+samodell@users.noreply.github.com> Date: Mon, 1 Apr 2019 14:05:20 -0700 Subject: [PATCH 2/2] Update docs/eventing/samples/iot-core/README.md Co-Authored-By: Harwayne --- docs/eventing/samples/iot-core/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/eventing/samples/iot-core/README.md b/docs/eventing/samples/iot-core/README.md index e630341dff5..5e7b3dfd05b 100644 --- a/docs/eventing/samples/iot-core/README.md +++ b/docs/eventing/samples/iot-core/README.md @@ -159,7 +159,7 @@ Core. We now have everything installed and ready to go. We will generate events and see them in the subscriber. -1. Run the following program to generate events. +1. Run the following program to generate events: ```shell go run github.com/knative/docs/docs/eventing/samples/iot-core/generator \