mirror of https://github.com/knative/docs.git
Update KubernetesEventSource to use ApiServerSource (#1307)
This commit is contained in:
parent
9f86f17c43
commit
40f3fd5725
|
@ -21,8 +21,8 @@ kubectl label namespace default knative-eventing-injection=enabled
|
||||||
|
|
||||||
### Service Account
|
### Service Account
|
||||||
|
|
||||||
1. Create a Service Account that the `Receive Adapter` runs as. The
|
1. Create a Service Account that the `ApiServerSource` runs as. The
|
||||||
`Receive Adapater` watches for Kubernetes events and forwards them to the
|
`ApiServerSource` watches for Kubernetes events and forwards them to the
|
||||||
Knative Eventing Broker. 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
|
with the appropriate permissions, you need to modify the
|
||||||
`serviceaccount.yaml`.
|
`serviceaccount.yaml`.
|
||||||
|
@ -44,11 +44,11 @@ kubectl apply --filename k8s-events.yaml
|
||||||
|
|
||||||
### Trigger
|
### Trigger
|
||||||
|
|
||||||
In order to check the `KubernetesEventSource` is fully working, we will create a
|
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
|
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.
|
||||||
|
|
||||||
1. If the deployed `KubernetesEventSource` is pointing at a `Broker` other than
|
1. If the deployed `ApiServerSource` is pointing at a `Broker` other than
|
||||||
`default`, modify `trigger.yaml` by adding `spec.broker` with the `Broker`'s
|
`default`, modify `trigger.yaml` by adding `spec.broker` with the `Broker`'s
|
||||||
name.
|
name.
|
||||||
|
|
||||||
|
@ -83,15 +83,62 @@ kubectl logs -l serving.knative.dev/service=event-display -c user-container
|
||||||
You should see log lines similar to:
|
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":""}
|
☁️ CloudEvent: valid ✅
|
||||||
Ce-Source: /apis/v1/namespaces/default/pods/busybox
|
Context Attributes,
|
||||||
{"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":""}
|
SpecVersion: 0.2
|
||||||
Ce-Source: /apis/v1/namespaces/default/pods/busybox
|
Type: dev.knative.apiserver.resource.add
|
||||||
|
Source: https://10.39.240.1:443
|
||||||
|
ID: 716d4536-3b92-4fbb-98d9-14bfcf94683f
|
||||||
|
Time: 2019-05-10T23:27:06.695575294Z
|
||||||
|
ContentType: application/json
|
||||||
|
Extensions:
|
||||||
|
knativehistory: default-broker-b7k2p-channel-z7mqq.default.svc.cluster.local
|
||||||
|
subject: /apis/v1/namespaces/default/events/busybox.159d7608e3a3572c
|
||||||
|
Transport Context,
|
||||||
|
URI: /
|
||||||
|
Host: auto-event-display.default.svc.cluster.local
|
||||||
|
Method: POST
|
||||||
|
Data,
|
||||||
|
{
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"count": 1,
|
||||||
|
"eventTime": null,
|
||||||
|
"firstTimestamp": "2019-05-10T23:27:06Z",
|
||||||
|
"involvedObject": {
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"fieldPath": "spec.containers{busybox}",
|
||||||
|
"kind": "Pod",
|
||||||
|
"name": "busybox",
|
||||||
|
"namespace": "default",
|
||||||
|
"resourceVersion": "28987493",
|
||||||
|
"uid": "1efb342a-737b-11e9-a6c5-42010a8a00ed"
|
||||||
|
},
|
||||||
|
"kind": "Event",
|
||||||
|
"lastTimestamp": "2019-05-10T23:27:06Z",
|
||||||
|
"message": "Started container",
|
||||||
|
"metadata": {
|
||||||
|
"creationTimestamp": "2019-05-10T23:27:06Z",
|
||||||
|
"name": "busybox.159d7608e3a3572c",
|
||||||
|
"namespace": "default",
|
||||||
|
"resourceVersion": "506088",
|
||||||
|
"selfLink": "/api/v1/namespaces/default/events/busybox.159d7608e3a3572c",
|
||||||
|
"uid": "2005af47-737b-11e9-a6c5-42010a8a00ed"
|
||||||
|
},
|
||||||
|
"reason": "Started",
|
||||||
|
"reportingComponent": "",
|
||||||
|
"reportingInstance": "",
|
||||||
|
"source": {
|
||||||
|
"component": "kubelet",
|
||||||
|
"host": "gke-knative-auto-cluster-default-pool-23c23c4f-xdj0"
|
||||||
|
},
|
||||||
|
"type": "Normal"
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Cleanup
|
### Cleanup
|
||||||
|
|
||||||
You can remove the `Service Account`, `Event Sources`, and `Trigger` via:
|
You can remove the `ServiceAccount`, `ClusterRoles`, `ClusterRoleBinding`,
|
||||||
|
`ApiSeverSource`, `Service` and `Trigger` via:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl --namespace default delete --filename serviceaccount.yaml
|
kubectl --namespace default delete --filename serviceaccount.yaml
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
title: "Kubernetes event source"
|
title: "Kubernetes Api Server Source"
|
||||||
linkTitle: "Kubernetes event"
|
linkTitle: "Kubernetes event"
|
||||||
weight: 50
|
weight: 50
|
||||||
type: "docs"
|
type: "docs"
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
apiVersion: sources.eventing.knative.dev/v1alpha1
|
apiVersion: sources.eventing.knative.dev/v1alpha1
|
||||||
kind: KubernetesEventSource
|
kind: ApiServerSource
|
||||||
metadata:
|
metadata:
|
||||||
name: testevents
|
name: testevents
|
||||||
spec:
|
|
||||||
namespace: default
|
namespace: default
|
||||||
|
spec:
|
||||||
serviceAccountName: events-sa
|
serviceAccountName: events-sa
|
||||||
|
mode: Resource
|
||||||
|
resources:
|
||||||
|
- apiVersion: v1
|
||||||
|
kind: Event
|
||||||
sink:
|
sink:
|
||||||
apiVersion: eventing.knative.dev/v1alpha1
|
apiVersion: eventing.knative.dev/v1alpha1
|
||||||
kind: Broker
|
kind: Broker
|
||||||
|
|
|
@ -7,9 +7,8 @@ metadata:
|
||||||
---
|
---
|
||||||
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
kind: Role
|
kind: ClusterRole
|
||||||
metadata:
|
metadata:
|
||||||
creationTimestamp: null
|
|
||||||
name: event-watcher
|
name: event-watcher
|
||||||
rules:
|
rules:
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
|
@ -24,15 +23,15 @@ rules:
|
||||||
---
|
---
|
||||||
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
kind: RoleBinding
|
kind: ClusterRoleBinding
|
||||||
metadata:
|
metadata:
|
||||||
creationTimestamp: null
|
|
||||||
name: k8s-ra-event-watcher
|
name: k8s-ra-event-watcher
|
||||||
roleRef:
|
roleRef:
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
kind: Role
|
kind: ClusterRole
|
||||||
name: event-watcher
|
name: event-watcher
|
||||||
subjects:
|
subjects:
|
||||||
- kind: ServiceAccount
|
- kind: ServiceAccount
|
||||||
name: events-sa
|
name: events-sa
|
||||||
namespace: default
|
namespace: default
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ spec:
|
||||||
name: event-display
|
name: event-display
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# This is a very simple Knative Service that writes the input request to its log.
|
# This is a very simple Knative Service that writes the input request to its log.
|
||||||
|
|
||||||
apiVersion: serving.knative.dev/v1alpha1
|
apiVersion: serving.knative.dev/v1alpha1
|
||||||
|
|
|
@ -36,7 +36,7 @@ These are sources that are installed as `CRD`s.
|
||||||
| [GitLab](https://gitlab.com/triggermesh/gitlabsource) | Proof of Concept | None | Registers for events of the specified types on the specified GitLab repository. Brings those events into Knative. |
|
| [GitLab](https://gitlab.com/triggermesh/gitlabsource) | Proof of Concept | None | Registers for events of the specified types on the specified GitLab repository. Brings those events into Knative. |
|
||||||
| [Google Cloud Scheduler](https://github.com/vaikas-google/csr) | Active Development | None | Create, update, and delete [Google Cloud Scheduler](https://cloud.google.com/scheduler/) Jobs. When those jobs are triggered, receive the event inside Knative. |
|
| [Google Cloud Scheduler](https://github.com/vaikas-google/csr) | Active Development | None | Create, update, and delete [Google Cloud Scheduler](https://cloud.google.com/scheduler/) Jobs. When those jobs are triggered, receive the event inside Knative. |
|
||||||
| [Google Cloud Storage](https://github.com/vaikas-google/gcs) | Active Development | None | Registers for events of the specified types on the specified Google Cloud Storage bucket and optional object prefix. Brings those events into Knative. |
|
| [Google Cloud Storage](https://github.com/vaikas-google/gcs) | Active Development | None | Registers for events of the specified types on the specified Google Cloud Storage bucket and optional object prefix. Brings those events into Knative. |
|
||||||
| [Kubernetes](https://github.com/knative/eventing-sources/blob/master/pkg/apis/sources/v1alpha1/kuberneteseventsource_types.go) | Active Development | Knative | Brings Kubernetes cluster events into Knative. Uses ContainerSource for underlying infrastructure. |
|
| [Kubernetes Api Server](https://github.com/knative/eventing/blob/master/pkg/apis/sources/v1alpha1/apiserver_types.go) | Active Development | Knative | Brings Kubernetes resource changes into Knative as references or as full resources. |
|
||||||
|
|
||||||
## Meta Sources
|
## Meta Sources
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue