Skip to content

Commit 24be444

Browse files
Harwayneknative-prow-robot
authored andcommitted
Update the kubernetes-event-source example to use Broker, rather than Channel. (#1091)
* Update the kubernetes-event-source example to use Broker, rather than Channel. * Simplify busybox. * Update docs/eventing/samples/kubernetes-event-source/README.md Co-Authored-By: Harwayne <[email protected]> * Update docs/eventing/samples/kubernetes-event-source/README.md Co-Authored-By: Harwayne <[email protected]> * Specify k8s-events.yaml.
1 parent 3353747 commit 24be444

File tree

5 files changed

+30
-45
lines changed

5 files changed

+30
-45
lines changed

docs/eventing/samples/kubernetes-event-source/README.md

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,19 @@ consumption by a function that has been implemented as a Knative Service.
88
1. Setup [Knative Serving](../../../serving).
99
1. Setup [Knative Eventing](../../../eventing).
1010

11-
### Channel
11+
### Broker
1212

13-
1. Create a `Channel`. You can use your own `Channel` or use the provided
14-
sample, which creates a channel called `testchannel`. If you use your own
15-
`Channel` with a different name, then you will need to alter other commands
16-
later.
13+
1. Create the `default` Broker in your namespace. These instructions assume the namespace `default`, feel free to change to any other namespace you would like to use instead. If you use a different namespace, you will need to modify all the YAML files deployed in this sample to point at that namespace.
1714

1815
```shell
19-
kubectl --namespace default apply --filename channel.yaml
16+
kubectl label namespace default knative-eventing-injection=enabled
2017
```
2118

2219
### Service Account
2320

2421
1. Create a Service Account that the `Receive Adapter` runs as. The
2522
`Receive Adapater` watches for Kubernetes events and forwards them to the
26-
Knative Eventing Framework. If you want to re-use an existing Service Account
23+
Knative Eventing Broker. If you want to re-use an existing Service Account
2724
with the appropriate permissions, you need to modify the
2825
`serviceaccount.yaml`.
2926

@@ -34,49 +31,44 @@ kubectl apply --filename serviceaccount.yaml
3431
### Create Event Source for Kubernetes Events
3532

3633
1. In order to receive events, you have to create a concrete Event Source for a
37-
specific namespace. If you are wanting to consume events from a different
38-
namespace or using a different `Service Account`, you need to modify the yaml
39-
accordingly.
34+
specific namespace. If you want to consume events from a different
35+
namespace or use a different `Service Account`, you need to modify
36+
`k8s-events.yaml` accordingly.
4037

4138
```shell
4239
kubectl apply --filename k8s-events.yaml
4340
```
4441

45-
### Subscriber
42+
### Trigger
4643

4744
In order to check the `KubernetesEventSource` is fully working, we will create a
48-
simple Knative Service that dumps incoming messages to its log and create a
49-
`Subscription` from the `Channel` to that Knative Service.
45+
simple Knative Service that dumps incoming messages to its log and creates a
46+
`Trigger` from the `Broker` to that Knative Service.
5047

51-
1. If the deployed `KubernetesEventSource` is pointing at a `Channel` other than
52-
`testchannel`, modify `subscription.yaml` by replacing `testchannel` with
53-
that `Channel`'s name.
54-
1. Deploy `subscription.yaml`.
48+
1. If the deployed `KubernetesEventSource` is pointing at a `Broker` other than
49+
`default`, modify `trigger.yaml` by adding `spec.broker` with the `Broker`'s name.
50+
51+
1. Deploy `trigger.yaml`.
5552

5653
```shell
57-
kubectl apply --filename subscription.yaml
54+
kubectl apply --filename trigger.yaml
5855
```
5956

6057
### Create Events
6158

6259
Create events by launching a pod in the default namespace. Create a busybox
63-
container
64-
65-
```shell
66-
kubectl run -i --tty busybox --image=busybox --restart=Never -- sh
67-
```
68-
69-
Once the shell comes up, just exit it and kill the pod.
60+
container and immediately delete it.
7061

7162
```shell
63+
kubectl run busybox --image=busybox --restart=Never -- ls
7264
kubectl delete pod busybox
7365
```
7466

7567
### Verify
7668

77-
We will verify that the kubernetes events were sent into the Knative eventing
69+
We will verify that the Kubernetes events were sent into the Knative eventing
7870
system by looking at our message dumper function logs. If you deployed the
79-
[Subscriber](#subscriber), then continue using this section. If not, then you
71+
[Trigger](#trigger), then continue using this section. If not, then you
8072
will need to look downstream yourself.
8173

8274
```shell

docs/eventing/samples/kubernetes-event-source/channel.yaml

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

docs/eventing/samples/kubernetes-event-source/k8s-events.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ spec:
77
serviceAccountName: events-sa
88
sink:
99
apiVersion: eventing.knative.dev/v1alpha1
10-
kind: Channel
11-
name: testchannel
10+
kind: Broker
11+
name: default

docs/eventing/samples/kubernetes-event-source/serviceaccount.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ kind: ServiceAccount
33
metadata:
44
name: events-sa
55
namespace: default
6+
67
---
8+
79
apiVersion: rbac.authorization.k8s.io/v1
810
kind: Role
911
metadata:
@@ -18,7 +20,9 @@ rules:
1820
- get
1921
- list
2022
- watch
23+
2124
---
25+
2226
apiVersion: rbac.authorization.k8s.io/v1
2327
kind: RoleBinding
2428
metadata:

docs/eventing/samples/kubernetes-event-source/subscription.yaml renamed to docs/eventing/samples/kubernetes-event-source/trigger.yaml

Lines changed: 5 additions & 7 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:
4-
name: testevents-subscription
4+
name: testevents-trigger
55
namespace: default
66
spec:
7-
channel:
8-
apiVersion: eventing.knative.dev/v1alpha1
9-
kind: Channel
10-
name: testchannel
117
subscriber:
128
ref:
139
apiVersion: serving.knative.dev/v1alpha1
@@ -28,4 +24,6 @@ spec:
2824
revisionTemplate:
2925
spec:
3026
container:
31-
image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/message_dumper@sha256:73a95b05b5b937544af7c514c3116479fa5b6acf7771604b313cfc1587bf0940
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)