Add docs from eventing sources (#496)

* Move samples from eventing-sources to this repo

* Remove old k8s-events in lieu of kubernetes-event-source
This commit is contained in:
Ville Aikas 2018-11-06 10:55:36 -08:00 committed by Knative Prow Robot
parent 37b2485245
commit 44cd74fe68
16 changed files with 347 additions and 461 deletions

View File

@ -0,0 +1,109 @@
# GCP Cloud Pub/Sub - Source
## Deployment Steps
### Prerequisites
1. Create a [Google Cloud Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects).
1. Enable the 'Cloud Pub/Sub API' on that project.
```shell
gcloud services enable pubsub.googleapis.com
```
1. Setup [Knative Eventing](https://github.com/knative/docs/tree/master/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.
1. Create a `Channel`. You can use your own `Channel` or use the provided sample, which creates `qux-1`. If you use your own `Channel` with a different name, then you will need to alter other commands later.
```shell
kubectl -n default apply -f eventing/samples/gcp-pubsub-source/channel.yaml
```
1. Create GCP [Service Account(s)](https://console.cloud.google.com/iam-admin/serviceaccounts/project). You can either create one with both permissions or two different ones for least privilege. If you create only one, then use the permissions for the `Source`'s Service Account (which is a superset of the Receive Adapter's permission) and provide the same key in both secrets.
- The `Source`'s Service Account.
1. Determine the Service Account to use, or create a new one.
1. Give that Service Account the 'Pub/Sub Editor' role on your GCP project.
1. Download a new JSON private key for that Service Account.
1. Create a secret for the downloaded key:
```shell
kubectl -n knative-sources create secret generic gcppubsub-source-key --from-file=key.json=PATH_TO_KEY_FILE.json
```
- Note that you can change the secret's name and the secret's key, but will need to modify `default-gcppubsub.yaml` in a later step with the updated values (they are environment variables on the `StatefulSet`).
- The Receive Adapter's Service Account.
1. Determine the Service Account to use, or create a new one.
1. Give that Service Account the 'Pub/Sub Subscriber' role on your GCP project.
1. Download a new JSON private key for that Service Account.
1. Create a secret for the downloaded key in the namespace that the `Source` will be created in:
```shell
kubectl -n default create secret generic google-cloud-key --from-file=key.json=PATH_TO_KEY_FILE.json
```
- Note that you can change the secret's name and the secret's key, but will need to modify `gcp-pubsub-source.yaml`'s `spec.gcpCredsSecret` in a later step with the updated values.
1. Create a GCP PubSub Topic. Replace `TOPIC-NAME` with your desired topic name.
```shell
gcloud pubsub topics create TOPIC-NAME
```
### Deployment
1. Deploy the `GcpPubSubSource` controller as part of eventing-source's controller.
```shell
kubectl apply -f https://knative-releases.storage.googleapis.com/eventing-sources/latest/release-with-gcppubsub.yaml
```
- Note that if the `Source` Service Account secret is in a non-default location, you will need to update the YAML first.
1. Replace the place holders in `gcp-pubsub-source.yaml`.
- `MY_GCP_PROJECT` should be replaced with your [Google Cloud Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects)'s ID.
- `TOPIC_NAME` should be replaced with your GCP PubSub Topic's name. It should be the unique portion within the project. E.g. `laconia`, not `projects/my-gcp-project/topics/laconia`.
- `qux-1` should be replaced with the name of the `Channel` you want messages sent to. If you deployed an unaltered `channel.yaml`, then you can leave it as `qux-1`.
- `gcpCredsSecret` should be replaced if you are using a non-default secret or key name for the receive adapter's credentials.
1. Deploy `gcp-pubsub-source.yaml`.
```shell
kubectl -n default apply -f eventing/samples/gcp-pubsub-source/gcp-pubsub-source.yaml
```
### Subscriber
In order to check the `GcpPubSubSource` 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.
1. Setup [Knative Serving](https://github.com/knative/docs/tree/master/serving).
1. If the deployed `GcpPubSubSource` is pointing at a `Channel` other than `qux-1`, modify `subscriber.yaml` by replacing `qux-1` with that `Channel`'s name.
1. Deploy `subscriber.yaml`.
```shell
ko -n default apply -f eventing/samples/gcp-pubsub-source/subscriber.yaml
```
### Publish
Publish messages to your GCP PubSub Topic.
```shell
gcloud pubsub topics publish TOPIC-NAME --message="Hello World!"
```
### Verify
We will verify that the published message was sent into the Knative eventing system by looking at what is downstream of the `GcpPubSubSource`. If you deployed the [Subscriber](#subscriber), then continue using this section. If not, then you will need to look downstream yourself.
1. Use [`kail`](https://github.com/boz/kail) to tail the logs of the subscriber.
```shell
kail -d message-dumper -c user-container --since=10m
```
You should see log lines similar to:
```
{"ID":"284375451531353","Data":"SGVsbG8gV29ybGQh","Attributes":null,"PublishTime":"2018-10-31T00:00:00.00Z"}
```

View File

@ -0,0 +1,10 @@
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
metadata:
name: qux-1
namespace: default
spec:
provisioner:
apiVersion: eventing.knative.dev/v1alpha1
kind: ClusterChannelProvisioner
name: in-memory-channel

View File

@ -0,0 +1,18 @@
# Replace the following before applying this file:
# TOPIC_NAME: Replace with the GCP PubSub Topic name.
# MY_GCP_PROJECT: Replace with the GCP Project's ID.
apiVersion: sources.eventing.knative.dev/v1alpha1
kind: GcpPubSubSource
metadata:
name: TOPIC_NAME-source
spec:
gcpCredsSecret:
name: google-cloud-key
key: key.json
googleCloudProject: MY_GCP_PROJECT
topic: TOPIC_NAME
sink:
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
name: qux-1

View File

@ -0,0 +1,34 @@
# Subscription from the GcpPubSubSource's output Channel to the Knative Service below.
apiVersion: eventing.knative.dev/v1alpha1
kind: Subscription
metadata:
name: gcppubsub-source-sample
namespace: default
spec:
from:
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
name: qux-1
call:
targetRef:
apiVersion: serving.knative.dev/v1alpha1
kind: Service
name: message-dumper
---
# This is a very simple Knative Service that writes the input request to its log.
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
name: message-dumper
namespace: default
spec:
runLatest:
configuration:
revisionTemplate:
spec:
container:
image: github.com/knative/eventing-sources/cmd/message_dumper

View File

@ -1,27 +0,0 @@
# Copyright 2018 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM golang AS builder
WORKDIR /go/src/github.com/knative/docs/
ADD . /go/src/github.com/knative/docs/
RUN CGO_ENABLED=0 go build ./eventing/samples/k8s-events
FROM gcr.io/distroless/base
COPY --from=builder /go/src/github.com/knative/docs/k8s-events /sample
ENTRYPOINT ["/sample"]
EXPOSE 8080

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

View File

@ -1,279 +0,0 @@
# Flow Example
A simple function which receives and logs Kubernetes Events. This examples uses
all the different components of the Knative Eventing stack with a `stub`
ClusterBus and the `k8sevents` EventSource. The function is deployed using a
Knative serving service, so it scales automatically as event traffic increases.
## Prerequisites
- A Kubernetes cluster with Knative installed. Follow the
[installation instructions](https://github.com/knative/docs/blob/master/install/README.md)
if you need to create one.
- [Docker](https://www.docker.com/) installed and running on your local machine,
and a Docker Hub account configured (you'll use it for a container registry).
- The core Knative eventing tools installed. You can install them with:
```shell
kubectl apply --filename https://storage.googleapis.com/knative-releases/eventing/latest/release.yaml
```
## Configuring Knative
To use this sample, you'll need to install the `stub` ClusterBus and the
`k8sevents` EventSource.
```shell
kubectl apply --filename https://storage.googleapis.com/knative-releases/eventing/latest/release-clusterbus-stub.yaml
kubectl apply --filename https://storage.googleapis.com/knative-releases/eventing/latest/release-source-k8sevents.yaml
```
## Granting permissions
Because the `k8sevent` EventSource needs to create a Deployment and call the
Kubernetes watch API on events, you'll need to provision a special
ServiceAccount with the necessary permissions.
The `serviceaccount.yaml` file provisions a service account, creates a role
which can create Deployments in the `default` namespace and can view all
Kubernetes resources. In a production environment, you might want to limit the
access of this service account to only specific namespaces.
```shell
kubectl apply --filename serviceaccount.yaml
```
## Build and deploy the sample
1. Use Docker to build the sample code into a container. To build and push with
Docker Hub, run these commands replacing `{username}` with your Docker Hub
username:
```shell
# Build the container on your local machine
# Note: The relative path points to the _root_ of the `knative/docs` repo
docker build -t {username}/k8s-events --file Dockerfile ../../../
# Push the container to docker registry
docker push {username}/k8s-events
```
1. After the build has completed and the container is pushed to Docker Hub, you
can deploy the function into your cluster. **Ensure that the container image
value in `function.yaml` matches the container you built in the previous
step.** Apply the configuration using `kubectl`:
```shell
kubectl apply --filename function.yaml
```
1. Check that your service is running using:
```shell
kubectl get ksvc --output "custom-columns=NAME:.metadata.name,READY:.status.conditions[2].status,REASON:.status.conditions[2].message"
NAME READY REASON
read-k8s-events True <none>
```
1. Create the flow sending Kubernetes Events to the service:
```shell
kubectl apply --filename flow.yaml
```
1. If you have the full knative install, you can read the function logs using
Kibana (see below if you are using a `lite` or `no-mon` install). To access
Kibana, you need to run `kubectl proxy` to start a local proxy to access the
logging stack:
```
kubectl proxy
Starting to serve on 127.0.0.1:8001
```
Then visit the
[Kibana interface](http://localhost:8001/api/v1/namespaces/knative-monitoring/services/kibana-logging/proxy/app/kibana#/discover%3F_g%3D%28%29%26_a%3D%28columns%3A%21%28log%29%2Cindex%3AAWSnR1TW-6k0tY2-zd9_%2Cinterval%3Aauto%2Cquery%3A%28query_string%3A%28query%3A%27kubernetes.container_name%3Auser-container+kubernetes.labels.serving_knative_dev%255C%252Fconfiguration%3Aread-k8s-events%27%29%29%2Csort%3A%21%28%27@timestamp%27%2Cdesc%29%29)
and search for the following string (or use the link above):
```
kubernetes.container_name:user-container kubernetes.labels.serving_knative_dev\/configuration:read-k8s-events
```
![Kibana log screenshot](Kibana.png)
If you are running a `lite` or `no-mon` install, you can use `kubectl logs` to read the logs from the pod:
```shell
kubectl get pods
# Find a pod with read-k8s-events prefix
kubectl logs read-k8s-events-....
```
## Understanding what happened
When the flow is created, it provisions the following resources:
1. A Feed resource to connect the specified EventSource to a Channel on the
bus:
```shell
kubectl get --output yaml feed k8s-event-flow-....
```
```yaml
apiVersion: feeds.knative.dev/v1alpha1
kind: Feed
metadata:
name: k8s-event-flow
namespace: default
spec:
action:
channelName: k8s-event-flow-channel.default.svc.cluster.local
serviceAccountName: feed-sa
trigger:
eventType: dev.knative.k8s.event
parameters:
namespace: default
resource: k8sevents/dev.knative.k8s.event
service: k8sevents
```
1. The `trigger` parameter on the Feed references an `eventType`, and provides
some parameters to that EventType:
```shell
kubectl get --output yaml eventtype dev.knative.k8s.event
```
```yaml
apiVersion: feeds.knative.dev/v1alpha1
kind: EventType
metadata:
name: dev.knative.k8s.event
namespace: default
spec:
description: subscription for receiving k8s cluster events
eventSource: k8sevents
```
1. In turn, the EventType references an `eventSource`. A single EventSource may
expose several different EventTypes, each of which provides different types
of events from the same source. At the moment, the k8sevents adapter only
knows how to listen for `corev1.Event` changes, but it's likely that other
sorts of object watches will be supported in the future.
```shell
kubectl get --output yaml eventsource k8sevents
```
```yaml
apiVersion: feeds.knative.dev/v1alpha1
kind: EventSource
metadata:
name: k8sevents
namespace: default
spec:
image: gcr.io/knative-releases/github.com/knative/eventing/pkg/sources/k8sevents@...
parameters:
image: gcr.io/knative-releases/github.com/knative/eventing/pkg/sources/k8sevents/receive_adapter@...
source: k8sevents
type: k8sevents
```
1. In addition to the `eventType` parameter, the Flow also referenced a Channel
by kubernetes service name (as `action.channelName`. You can find the
channel object by examining the `ownerReferences` on the Service:
```shell
kubectl get --output yaml svc k8s-event-flow-channel
```
```yaml
apiVersion: v1
kind: Service
metadata:
labels:
channel: k8s-event-flow
name: k8s-event-flow-channel
namespace: default
ownerReferences:
- apiVersion: channels.knative.dev/v1alpha1
blockOwnerDeletion: true
controller: true
kind: Channel
name: k8s-event-flow
uid: 234b1269-8e5d-11e8-aae1-42010a8a001e
spec:
...
```
1. A Channel is the network address of a message dispatch queue on a Bus. The
Channel and Bus provide a one-to-many messaging layer with optional
persistence. Each Channel is associated with either a Bus or a ClusterBus:
```shell
kubectl get --output yaml channel k8s-event-flow
```
```yaml
apiVersion: channels.knative.dev/v1alpha1
kind: Channel
metadata:
name: k8s-event-flow
namespace: default
spec:
clusterBus: stub
```
1. In this case, you can see that the `k8s-event-flow` Channel references the
`stub` ClusterBus. Knative eventing supports both ClusterBuses, provisioned
by a cluster administrator, and namespace-local Buses, which are useful for
development or resource isolation. Typically, many users may share a
persistent ClusterBus backed by a broker such as Kafka or Google PubSub. In
these cases, the cluster administrator would create and manage both the
underlying Kafka cluster and the ClusterBus definition. The `stub` bus is a
simple in-memory forwarder with no dependencies, which is great for demos
but will not durably store messages if the connected endpoints are down.
```shell
kubectl get --output yaml clusterbus stub
```
```yaml
apiVersion: channels.knative.dev/v1alpha1
kind: ClusterBus
metadata:
name: stub
spec:
dispatcher:
args:
- -logtostderr
- -stderrthreshold
- INFO
image: gcr.io/knative-releases/github.com/knative/eventing/pkg/buses/stub@...
name: dispatcher
resources: {}
```
1. So far, you've explored how the events are collected from Kubernetes by the
Feed and forwarded to the Bus. The last piece of the puzzle is how the
events are forwarded from the Bus to your function. This is handled by a
Subscription:
```shell
kubectl get --output yaml subscription k8s-event-flow
```
```yaml
- apiVersion: channels.knative.dev/v1alpha1
kind: Subscription
metadata:
name: k8s-event-flow
namespace: default
spec:
channel: k8s-event-flow
subscriber: read-k8s-events.default.svc.cluster.local
```
A Subscription links a channel to an interested recipient of the events; in
this case, the `k8s-event-flow` Channel with our `read-k8s-events` Knative
Service.

View File

@ -1,32 +0,0 @@
# Copyright 2018 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: flows.knative.dev/v1alpha1
kind: Flow
metadata:
name: k8s-event-flow
namespace: default
spec:
serviceAccountName: feed-sa
trigger:
eventType: dev.knative.k8s.event
resource: k8sevents/dev.knative.k8s.event
service: k8sevents
parameters:
namespace: default
action:
target:
kind: Route
apiVersion: serving.knative.dev/v1alpha1
name: read-k8s-events

View File

@ -1,38 +0,0 @@
/*
Copyright 2018 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"context"
"log"
"net/http"
"time"
corev1 "k8s.io/api/core/v1"
"github.com/knative/eventing/pkg/event"
)
func handler(ctx context.Context, e *corev1.Event) {
metadata := event.FromContext(ctx)
log.Printf("[%s] %s : %q", metadata.EventTime.Format(time.RFC3339), metadata.Source, e.Message)
}
func main() {
log.Print("Ready and listening on port 8080")
log.Fatal(http.ListenAndServe(":8080", event.Handler(handler)))
}

View File

@ -1,27 +0,0 @@
# Copyright 2018 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
name: read-k8s-events
namespace: default
spec:
runLatest:
configuration:
revisionTemplate:
spec:
container:
# Replace this image with your {username}/k8s-events container
image: docker.io/{username}/k8s-events

View File

@ -1,58 +0,0 @@
# Copyright 2018 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: v1
kind: ServiceAccount
metadata:
name: feed-sa
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: create-deployment
namespace: default
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list", "watch", "create", "update", "delete", "patch"]
---
# This enables the feed-sa to deploy the receive adapter.
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: feed-sa-deploy
namespace: default
subjects:
- kind: ServiceAccount
name: feed-sa
namespace: default
roleRef:
kind: Role
name: create-deployment
apiGroup: rbac.authorization.k8s.io
---
# This enables reading k8s events from all namespaces.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: feed-admin
subjects:
- kind: ServiceAccount
name: feed-sa
namespace: default
roleRef:
kind: ClusterRole
name: view
apiGroup: rbac.authorization.k8s.io
---

View File

@ -0,0 +1,91 @@
# Kubernetes Event Source example
Kubernetes Event Source example shows how to wire kubernetes cluster events for
consumption by a function that has been implemented as a Knative Service.
## Deployment Steps
### Prerequisites
1. Setup [Knative Eventing](https://github.com/knative/docs/tree/master/eventing).
1. Install [Knative Eventing Sources](https://github.com/knative/docs/tree/master/eventing-sources).
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.
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.
```shell
kubectl -n default apply -f eventing/samples/kubernetes-event-source/channel.yaml
```
### 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 with the appropriate permissions, you need to modify the
```shell
kubectl apply -f eventing/samples/kubernetes-event-source/serviceaccount.yaml
```
### Deploy Event Sources
1. Deploy the `KubernetesEventSource` controller as part of eventing-source's controller. This makes kubernetes events available for subscriptions.
```shell
ko apply -f config/default.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 differenet namespace or using a different `Service Account`, you need to modify the yaml accordingly.
```shell
kubectl apply -f eventing/samples/kubernetes-event-source/k8s-events.yaml
```
### Subscriber
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.
1. Setup [Knative Serving](https://github.com/knative/docs/tree/master/serving).
1. If the deployed `KubernetesEventSource` is pointing at a `Channel` other than `testchannel`, modify `subscriber.yaml` by replacing `testchannel` with that `Channel`'s name.
1. Deploy `subscriber.yaml`.
```shell
ko apply -f eventing/samples/kubernetes-event-source/subscription.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.
```shell
kubectl delete pods busybox
```
### Verify
We will verify that the kubernetes events were sent into the Knative eventing system by looking at our message dumper function logsIf you deployed the [Subscriber](#subscriber), then continue using this section. If not, then you will need to look downstream yourself.
```shell
kubectl get pods
kubectl logs message-dumper-XXXX user-container
```
You should see log lines similar to:
```
{"metadata":{"name":"busybox.15644359eaa4d8e7","namespace":"default","selfLink":"/api/v1/namespaces/default/events/busybox.15644359eaa4d8e7","uid":"daf8d3ca-e10d-11e8-bf3c-42010a8a017d","resourceVersion":"7840","creationTimestamp":"2018-11-05T15:17:05Z"},"involvedObject":{"kind":"Pod","namespace":"default","name":"busybox","uid":"daf645df-e10d-11e8-bf3c-42010a8a017d","apiVersion":"v1","resourceVersion":"681388"},"reason":"Scheduled","message":"Successfully assigned busybox to gke-knative-eventing-e2e-default-pool-575bcad9-vz55","source":{"component":"default-scheduler"},"firstTimestamp":"2018-11-05T15:17:05Z","lastTimestamp":"2018-11-05T15:17:05Z","count":1,"type":"Normal","eventTime":null,"reportingComponent":"","reportingInstance":""}
Ce-Source: /apis/v1/namespaces/default/pods/busybox
{"metadata":{"name":"busybox.15644359f59f72f2","namespace":"default","selfLink":"/api/v1/namespaces/default/events/busybox.15644359f59f72f2","uid":"db14ff23-e10d-11e8-bf3c-42010a8a017d","resourceVersion":"7841","creationTimestamp":"2018-11-05T15:17:06Z"},"involvedObject":{"kind":"Pod","namespace":"default","name":"busybox","uid":"daf645df-e10d-11e8-bf3c-42010a8a017d","apiVersion":"v1","resourceVersion":"681389"},"reason":"SuccessfulMountVolume","message":"MountVolume.SetUp succeeded for volume \"default-token-pzr6x\" ","source":{"component":"kubelet","host":"gke-knative-eventing-e2e-default-pool-575bcad9-vz55"},"firstTimestamp":"2018-11-05T15:17:06Z","lastTimestamp":"2018-11-05T15:17:06Z","count":1,"type":"Normal","eventTime":null,"reportingComponent":"","reportingInstance":""}
Ce-Source: /apis/v1/namespaces/default/pods/busybox
```

View File

@ -0,0 +1,9 @@
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
metadata:
name: testchannel
spec:
provisioner:
apiVersion: eventing.knative.dev/v1alpha1
kind: ClusterChannelProvisioner
name: in-memory-channel

View File

@ -0,0 +1,11 @@
apiVersion: sources.eventing.knative.dev/v1alpha1
kind: KubernetesEventSource
metadata:
name: testevents
spec:
namespace: default
serviceAccountName: events-sa
sink:
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
name: testchannel

View File

@ -0,0 +1,34 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: events-sa
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
creationTimestamp: null
name: event-watcher
rules:
- apiGroups:
- ""
resources:
- events
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
creationTimestamp: null
name: k8s-ra-event-watcher
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: event-watcher
subjects:
- kind: ServiceAccount
name: events-sa
namespace: default

View File

@ -0,0 +1,31 @@
apiVersion: eventing.knative.dev/v1alpha1
kind: Subscription
metadata:
name: testevents-subscription
namespace: default
spec:
channel:
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
name: testchannel
subscriber:
ref:
apiVersion: serving.knative.dev/v1alpha1
kind: Service
name: message-dumper
---
# This is a very simple Knative Service that writes the input request to its log.
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
name: message-dumper
namespace: default
spec:
runLatest:
configuration:
revisionTemplate:
spec:
container:
image: github.com/knative/eventing-sources/cmd/message_dumper