Skip to content

Commit 88f3afb

Browse files
Harwayneknative-prow-robot
authored andcommitted
Update the iot-core demo to use Broker rather than Channel (#1103)
* Update the iot-core demo to use Broker rather than Channel. Also remove ko and kail usage. * Update docs/eventing/samples/iot-core/README.md Co-Authored-By: Harwayne <[email protected]>
1 parent cb504f0 commit 88f3afb

File tree

4 files changed

+39
-75
lines changed

4 files changed

+39
-75
lines changed

docs/eventing/samples/iot-core/README.md

Lines changed: 32 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export IOTCORE_PROJECT="s9-demo"
2424
#### Variables you may Change
2525

2626
```shell
27-
export CHANNEL_NAME="iot-demo"
2827
export IOTCORE_REGISTRY="iot-demo"
2928
export IOTCORE_DEVICE="iot-demo-client"
3029
export IOTCORE_REGION="us-central1"
@@ -34,12 +33,6 @@ export IOTCORE_TOPIC_DEVICE="iot-demo-device-pubsub-topic"
3433

3534
### Prerequisites
3635

37-
#### Local
38-
39-
1. Clone
40-
[Knative Eventing Sources](https://github.com/knative/eventing-sources)
41-
locally.
42-
4336
#### Kubernetes
4437

4538
1. Have a running Kubernetes cluster with `kubectl` pointing at it.
@@ -67,13 +60,6 @@ export IOTCORE_TOPIC_DEVICE="iot-demo-device-pubsub-topic"
6760

6861
1. Setup [Knative Eventing](../../../eventing).
6962

70-
1. Install the
71-
[in-memory `ClusterChannelProvisioner`](https://github.com/knative/eventing/tree/master/config/provisioners/in-memory-channel).
72-
73-
- Note that you can skip this if you choose to use a different type of
74-
`Channel`. If so, you will need to modify `channel.yaml` before deploying
75-
it.
76-
7763
#### GCP PubSub Source
7864

7965
1. Create a GCP
@@ -94,44 +80,39 @@ export IOTCORE_TOPIC_DEVICE="iot-demo-device-pubsub-topic"
9480
controller.
9581
9682
```shell
97-
pushd $HOME/go/src/github.com/knative/eventing-sources
98-
ko apply --filename config/default-gcppubsub.yaml
99-
popd
83+
kubectl apply --filename https://github.com/knative/eventing-sources/releases/download/v0.5.0/gcppubsub.yaml
10084
```
10185
10286
### Deploying
10387
104-
#### Channel
88+
#### Broker
10589
106-
1. Create a `Channel`.
90+
1. Install the default `Broker`.
10791
10892
```shell
109-
sed "s/CHANNEL_NAME/$CHANNEL_NAME/" channel.yaml |
110-
kubectl --namespace default apply --filename -
93+
kubectl label namespace default knative-eventing-injection=enabled
11194
```
11295
11396
#### GCP PubSub Source
11497
11598
1. Deploy `gcp-pubsub-source.yaml`.
11699
117100
```shell
118-
sed -e "s/MY_GCP_PROJECT/$IOTCORE_PROJECT/" \
101+
sed -e "s/PROJECT_ID/$IOTCORE_PROJECT/" \
119102
-e "s/TOPIC_NAME/$IOTCORE_TOPIC_DATA/" \
120-
-e "s/CHANNEL_NAME/$CHANNEL_NAME/" \
121-
gcp-pubsub-source.yaml |
103+
docs/eventing/samples/iot-core/gcp-pubsub-source.yaml |
122104
kubectl apply --filename -
123105
```
124106
125-
#### Subscription
107+
#### Trigger
126108
127109
Even though the `Source` isn't completely ready yet, we can setup the
128-
`Subscription` for all events coming out of it.
110+
`Trigger` for all events coming out of it.
129111

130-
1. Deploy `subscription.yaml`.
112+
1. Deploy `trigger.yaml`.
131113

132114
```shell
133-
sed "s/CHANNEL_NAME/$CHANNEL_NAME/" subscription.yaml |
134-
ko apply --filename -
115+
kubectl apply --filename docs/eventing/samples/iot-core/trigger.yaml
135116
```
136117

137118
- This uses a very simple Knative Service to see that events are flowing.
@@ -178,14 +159,7 @@ Core.
178159
We now have everything installed and ready to go. We will generate events and
179160
see them in the subscriber.
180161

181-
1. Setup [`kail`](https://github.com/boz/kail) to tail the logs of the
182-
subscriber.
183-
184-
```shell
185-
kail -d message-dumper -c user-container
186-
```
187-
188-
1. In a separate terminal, run the following program to generate events.
162+
1. Run the following program to generate events:
189163

190164
```shell
191165
go run github.com/knative/docs/docs/eventing/samples/iot-core/generator \
@@ -199,37 +173,39 @@ see them in the subscriber.
199173
-events 10
200174
```
201175

176+
1. Inspect the logs of the subscriber:
177+
178+
```shell
179+
kubectl logs --selector serving.knative.dev/service=message-dumper -c user-container
180+
```
181+
182+
You should see something along the similar to:
183+
184+
```shell
185+
{"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"}
186+
202187
### Cleanup
203188
204189
To cleanup the knative resources:
205190
206-
1. Remove the gcppubsub controller:
191+
1. Remove the `GcpPubSubSource`:
207192
208193
```shell
209-
pushd $HOME/go/src/github.com/knative/eventing-sources
210-
kubectl delete --filename config/default-gcppubsub.yaml
211-
popd
194+
sed -e "s/PROJECT_ID/$IOTCORE_PROJECT/" \
195+
-e "s/TOPIC_NAME/$IOTCORE_TOPIC_DATA/" \
196+
docs/eventing/samples/iot-core/gcp-pubsub-source.yaml |
197+
kubectl delete --filename -
212198
```
213-
214-
2. Remove the channel:
199+
200+
1. Remove the Trigger:
215201

216202
```shell
217-
sed "s/CHANNEL_NAME/$CHANNEL_NAME/" channel.yaml |
218-
kubectl --namespace default delete --filename -
203+
kubectl delete --filename docs/eventing/samples/iot-core/trigger.yaml
219204
```
220205

221-
3. Remove the gcppubsub source:
206+
1. Remove the `GcpPubSubSource` controller:
222207

223208
```shell
224-
sed -e "s/MY_GCP_PROJECT/$IOTCORE_PROJECT/" \
225-
-e "s/TOPIC_NAME/$IOTCORE_TOPIC_DATA/" \
226-
-e "s/CHANNEL_NAME/$CHANNEL_NAME/" \
227-
gcp-pubsub-source.yaml |
228-
kubectl delete --filename -
209+
kubectl delete --filename https://github.com/knative/eventing-sources/releases/download/v0.5.0/gcppubsub.yaml
229210
```
230211

231-
4. Remove the subscription:
232-
```shell
233-
sed "s/CHANNEL_NAME/$CHANNEL_NAME/" subscription.yaml |
234-
kubectl delete --filename -
235-
```

docs/eventing/samples/iot-core/channel.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/eventing/samples/iot-core/gcp-pubsub-source.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ spec:
1010
gcpCredsSecret:
1111
name: google-cloud-key
1212
key: key.json
13-
googleCloudProject: MY_GCP_PROJECT
13+
googleCloudProject: PROJECT_ID
1414
topic: TOPIC_NAME
1515
sink:
1616
apiVersion: eventing.knative.dev/v1alpha1
17-
kind: Channel
18-
name: CHANNEL_NAME
17+
kind: Broker
18+
name: default

docs/eventing/samples/iot-core/subscription.yaml renamed to docs/eventing/samples/iot-core/trigger.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
apiVersion: eventing.knative.dev/v1alpha1
2-
kind: Subscription
2+
kind: Trigger
33
metadata:
44
name: iot-demo
55
namespace: default
66
spec:
7-
channel:
8-
apiVersion: eventing.knative.dev/v1alpha1
9-
kind: Channel
10-
name: CHANNEL_NAME
117
subscriber:
128
ref:
139
apiVersion: serving.knative.dev/v1alpha1
@@ -28,4 +24,6 @@ spec:
2824
revisionTemplate:
2925
spec:
3026
container:
31-
image: github.com/knative/eventing-sources/cmd/message_dumper
27+
# This corresponds to
28+
# https://github.com/knative/eventing-sources/blob/release-0.3/cmd/message_dumper/dumper.go
29+
image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/message_dumper@sha256:8423232db7a7b4010c0cfbfaef95745efe962631af9b7456903825801a7893f7

0 commit comments

Comments
 (0)