Skip to content
Merged
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
59 changes: 30 additions & 29 deletions docs/eventing/samples/kubernetes-event-source/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Kubernetes Event Source example shows how to wire kubernetes cluster events for
consumption by a function that has been implemented as a Knative Service. The code for the following files can be found in the [/kubernetes-event-source/](https://github.com/knative/docs/tree/master/docs/eventing/samples/kubernetes-event-source) directory.
consumption by a function that has been implemented as a Knative Service. The
code for the following files can be found in the
[/kubernetes-event-source/](https://github.com/knative/docs/tree/master/docs/eventing/samples/kubernetes-event-source)
directory.

## Deployment Steps

Expand All @@ -23,9 +26,8 @@ kubectl label namespace default knative-eventing-injection=enabled

1. Create a Service Account that the `ApiServerSource` runs as. The
`ApiServerSource` watches for Kubernetes events and forwards them to the
Knative Eventing Broker.
Create a file named `serviceaccount.yaml` and copy the code block
below into it.
Knative Eventing Broker. Create a file named `serviceaccount.yaml` and copy
the code block below into it.

```yaml
apiVersion: v1
Expand All @@ -35,23 +37,21 @@ metadata:
namespace: default

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: event-watcher
rules:
- apiGroups:
- ""
resources:
- events
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- get
- list
- watch

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand All @@ -61,14 +61,16 @@ roleRef:
kind: ClusterRole
name: event-watcher
subjects:
- kind: ServiceAccount
name: events-sa
namespace: default
- kind: ServiceAccount
name: events-sa
namespace: default
```

If you want to re-use an existing Service Account with the appropriate permissions, you need to modify the `serviceaccount.yaml`.
If you want to re-use an existing Service Account with the appropriate
permissions, you need to modify the `serviceaccount.yaml`.

Enter the following command to create the service account from `serviceaccount.yaml`:
Enter the following command to create the service account from
`serviceaccount.yaml`:

```shell
kubectl apply --filename serviceaccount.yaml
Expand All @@ -77,7 +79,7 @@ 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. Create a file named `k8s-events.yaml` and copy the code
specific namespace. Create a file named `k8s-events.yaml` and copy the code
block below into it.

```yaml
Expand All @@ -90,16 +92,16 @@ spec:
serviceAccountName: events-sa
mode: Resource
resources:
- apiVersion: v1
kind: Event
- apiVersion: v1
kind: Event
sink:
apiVersion: eventing.knative.dev/v1alpha1
kind: Broker
name: default
```

If you want to consume events from a different namespace or use a different
`Service Account`, you need to modify `k8s-events.yaml` accordingly.
If you want to consume events from a different namespace or use a different
`Service Account`, you need to modify `k8s-events.yaml` accordingly.

Enter the following command to create the event source:

Expand All @@ -111,7 +113,7 @@ kubectl apply --filename k8s-events.yaml

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

Create a file named `trigger.yaml` and copy the code block below into it.

Expand All @@ -129,7 +131,6 @@ spec:
name: event-display

---

# This is a very simple Knative Service that writes the input request to its log.

apiVersion: serving.knative.dev/v1beta1
Expand All @@ -141,9 +142,9 @@ spec:
template:
spec:
containers:
- # This corresponds to
# https://github.com/knative/eventing-contrib/blob/release-0.5/cmd/event_display/main.go
image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/event_display@sha256:bf45b3eb1e7fc4cb63d6a5a6416cf696295484a7662e0cf9ccdf5c080542c21d
- # This corresponds to
# https://github.com/knative/eventing-contrib/blob/release-0.5/cmd/event_display/main.go
image: gcr.io/knative-releases/github.com/knative/eventing-sources/cmd/event_display@sha256:bf45b3eb1e7fc4cb63d6a5a6416cf696295484a7662e0cf9ccdf5c080542c21d
```

1. If the deployed `ApiServerSource` is pointing at a `Broker` other than
Expand Down