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
46 changes: 19 additions & 27 deletions docs/eventing/samples/kubernetes-event-source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,19 @@ consumption by a function that has been implemented as a Knative Service.
1. Setup
[Knative Eventing](../../../eventing).

### Channel
### Broker

1. Create a `Channel`. You can use your own `Channel` or use the provided
sample, which creates a channel called `testchannel`. If you use your own
`Channel` with a different name, then you will need to alter other commands
later.
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.

```shell
kubectl --namespace default apply --filename channel.yaml
kubectl label namespace default knative-eventing-injection=enabled
```

### Service Account

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

Expand All @@ -36,49 +33,44 @@ kubectl apply --filename serviceaccount.yaml
### Create Event Source for Kubernetes Events

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

```shell
kubectl apply --filename k8s-events.yaml
```

### Subscriber
### Trigger

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

1. If the deployed `KubernetesEventSource` is pointing at a `Channel` other than
`testchannel`, modify `subscription.yaml` by replacing `testchannel` with
that `Channel`'s name.
1. Deploy `subscription.yaml`.
1. If the deployed `KubernetesEventSource` is pointing at a `Broker` other than
`default`, modify `trigger.yaml` by adding `spec.broker` with the `Broker`'s name.

1. Deploy `trigger.yaml`.

```shell
kubectl apply --filename subscription.yaml
kubectl apply --filename trigger.yaml
```

### Create Events

Create events by launching a pod in the default namespace. Create a busybox
container

```shell
kubectl run -i --tty busybox --image=busybox --restart=Never -- sh
```

Once the shell comes up, just exit it and kill the pod.
container and immediately delete it.

```shell
kubectl run busybox --image=busybox --restart=Never -- ls
kubectl delete pod busybox
```

### Verify

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

```shell
Expand Down
9 changes: 0 additions & 9 deletions docs/eventing/samples/kubernetes-event-source/channel.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions docs/eventing/samples/kubernetes-event-source/k8s-events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ spec:
serviceAccountName: events-sa
sink:
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
name: testchannel
kind: Broker
name: default
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ kind: ServiceAccount
metadata:
name: events-sa
namespace: default

---

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
Expand All @@ -18,7 +20,9 @@ rules:
- get
- list
- watch

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
apiVersion: eventing.knative.dev/v1alpha1
kind: Subscription
kind: Trigger
metadata:
name: testevents-subscription
name: testevents-trigger
namespace: default
spec:
channel:
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
name: testchannel
subscriber:
ref:
apiVersion: serving.knative.dev/v1alpha1
Expand All @@ -28,4 +24,6 @@ spec:
revisionTemplate:
spec:
container:
image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/message_dumper@sha256:73a95b05b5b937544af7c514c3116479fa5b6acf7771604b313cfc1587bf0940
# 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