Skip to content

Commit ffb93b2

Browse files
authored
Clean up sources docs (#4304)
* Edit PR #4301 * Tweak other sources pages to match * make v1 badges green * Update event display image
1 parent 947f487 commit ffb93b2

File tree

10 files changed

+67
-155
lines changed

10 files changed

+67
-155
lines changed

docs/developer/eventing/sources/apiserversource/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ApiServerSource
22

3-
![version](https://img.shields.io/badge/API_Version-v1-red?style=flat-square)
3+
![version](https://img.shields.io/badge/API_Version-v1-green?style=flat-square)
44

55
The API server source is a Knative Eventing Kubernetes custom resource that listens for events emitted by the
66
Kubernetes API server (eg. pod creation, deployment updates, etc...) and forwards them as CloudEvents to a sink.

docs/developer/eventing/sources/apiserversource/getting-started.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ command:
2626

2727
!!! note
2828
Creating a namespace for your ApiServerSource and related components
29-
allows you to view changes and events for this workflow more easily, since
30-
these are isolated from the many other components that may exist in your `default` namespace.<br><br>
31-
It also makes removing the source easier, since you can simply delete the namespace to remove all of the resources.
29+
allows you to view changes and events for this workflow more easily, because
30+
these are isolated from the other components that might exist in your `default` namespace.<br><br>
31+
It also makes removing the source easier, because you can delete the namespace to remove all of the resources.
3232

3333
1. Create a ServiceAccount:
3434

@@ -65,10 +65,11 @@ command:
6565
rules:
6666
<rules>
6767
```
68-
Where
69-
- `<role>` is the name of the Role that you want to create.
70-
- `<rules>` are the set of permissions you want to grant to the APIServerSource object. This set of permissions must match the resources you want to received events from.
68+
Where:
7169

70+
- `<role>` is the name of the Role that you want to create.
71+
- `<rules>` are the set of permissions you want to grant to the APIServerSource object.
72+
This set of permissions must match the resources you want to receive events from.
7273
For example, to receive events related to the `events` resource, use the following set of permissions:
7374
```yaml
7475
- apiGroups:
@@ -81,8 +82,8 @@ command:
8182
- watch
8283
```
8384

84-
!!! note
85-
The only required verbs are `get`, `list` and `watch`.
85+
!!! note
86+
The only required verbs are `get`, `list` and `watch`.
8687

8788
1. Apply the YAML file by running the command:
8889

@@ -112,7 +113,7 @@ command:
112113
Where:
113114

114115
- `<role-binding>` is the name of the RoleBinding that you want to create.
115-
- `<cluster-role>` is the name of the Role that you created in step 3 earlier.
116+
- `<role>` is the name of the Role that you created in step 3 earlier.
116117
- `<service-account>` is the name of the ServiceAccount that you created in step 2 earlier.
117118
- `<namespace>` is the name of the namespace that you created in step 1 earlier.
118119

@@ -144,7 +145,7 @@ command:
144145
spec:
145146
containers:
146147
- name: event-display
147-
image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display
148+
image: gcr.io/knative-releases/knative.dev/eventing/cmd/event_display
148149
149150
---
150151
@@ -191,14 +192,16 @@ command:
191192
- `<service-account>` is the name of the ServiceAccount that you created in step 2 earlier.
192193
- `<sink-name>` is the name of your sink, for example, `http://event-display.pingsource-example.svc.cluster.local`.
193194

195+
For a list of available options, see the [Knative client documentation](https://github.com/knative/client/blob/main/docs/cmd/kn_source_apiserver_create.md#kn-source-apiserver-create).
196+
194197
=== "YAML"
195198
1. Create a YAML file using the following template:
196199

197200
```yaml
198201
apiVersion: sources.knative.dev/v1
199202
kind: ApiServerSource
200203
metadata:
201-
name: <apiserversource>
204+
name: <apiserversource-name>
202205
namespace: <namespace>
203206
spec:
204207
serviceAccountName: <service-account>
@@ -214,13 +217,15 @@ command:
214217
```
215218
Where:
216219

217-
- `<apiserversource>` is the name of the source that you want to create.
220+
- `<apiserversource-name>` is the name of the source that you want to create.
218221
- `<namespace>` is the name of the namespace that you created in step 1 earlier.
219222
- `<service-account>` is the name of the ServiceAccount that you created in step 2 earlier.
220223
- `<event-mode>` is either `Resource` or `Reference`. If set to `Resource`, the event payload contains the entire resource that the event is for. If set to `Reference`, the event payload only contains a reference to the resource that the event is for. The default is `Reference`.
221-
- `<sink-kind>` is any supported [Addressable](https://knative.dev/docs/developer/concepts/duck-typing/#addressable) object that you want to use as a sink, for example, `Service` or `Deployment`.
224+
- `<sink-kind>` is any supported [Addressable](../../../concepts/duck-typing.md#addressable) object that you want to use as a sink, for example, `Service` or `Deployment`.
222225
- `<sink-name>` is the name of your sink.
223226

227+
For more information about the fields you can configure for the ApiServerSource object, see [ApiServerSource reference](reference.md).
228+
224229
1. Apply the YAML file by running the command:
225230

226231
```bash
@@ -230,14 +235,14 @@ command:
230235

231236
## Verify the ApiServerSource object
232237

233-
1. Make the Kubernetes API server create events by launching a test pod in your namespace by running the command:
238+
1. Make the Kubernetes API server create events by launching a test Pod in your namespace by running the command:
234239

235240
```bash
236241
kubectl run busybox --image=busybox --namespace=<namespace> --restart=Never -- ls
237242
```
238243
Where `<namespace>` is the name of the namespace that you created in step 1 earlier.
239244

240-
1. Delete the test pod by running the command:
245+
1. Delete the test Pod by running the command:
241246

242247
```bash
243248
kubectl --namespace=<namespace> delete pod busybox
@@ -308,7 +313,7 @@ command:
308313
}
309314
```
310315

311-
## Delete the ApiServerSource
316+
## Delete the ApiServerSource object
312317

313318
To remove the ApiServerSource object and all of the related resources:
314319

docs/developer/eventing/sources/apiserversource/reference.md

Lines changed: 25 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ An ApiServerSource definition supports the following fields:
2020
| `spec.mode` | EventMode controls the format of the event. Set to `Reference` to send a `dataref` event type for the resource being watched. Only a reference to the resource is included in the event payload. Set to `Resource` to have the full resource lifecycle event in the payload. Defaults to `Reference`. | Optional |
2121
| [`spec.owner`](#owner-parameter) | ResourceOwner is an additional filter to only track resources that are owned by a specific resource type. If ResourceOwner matches Resources[n] then Resources[n] is allowed to pass the ResourceOwner filter. | Optional |
2222
| [`spec.serviceAccountName`](#serviceaccountname-parameter) | The name of the ServiceAccount to use to run this source. Defaults to `default` if not set. | Optional |
23-
| [`spec.sink`](#sink-parameter) | A reference to an object that resolves to a URI to use as the sink. | Required |
23+
| [`spec.sink`](../../sinks/README.md#sink-as-a-parameter) | A reference to an object that resolves to a URI to use as the sink. | Required |
2424
| [`spec.ceOverrides`](#cloudevent-overrides) | Defines overrides to control the output format and modifications to the event sent to the sink. | Optional |
2525

2626

@@ -113,28 +113,32 @@ spec:
113113

114114
ServiceAccountName is a reference to a Kubernetes service account.
115115

116-
The proper permissions need to be assigned to the ApiServerSource object in order
117-
to track the lifecycle events of the specified [`resources`](#resources-parameter).
116+
To track the lifecycle events of the specified [`resources`](#resources-parameter),
117+
you must assign the proper permissions to the ApiServerSource object.
118118

119-
#### Example: tracking pods
119+
#### Example: tracking Pods
120120

121-
The following 4 YAMLs create a ServiceAccount, Role and RoleBinding
122-
and grant the permission to get, list and watch Pod resources in `<namespace>` for the
123-
ApiServerSource.
121+
The following YAML files create a ServiceAccount, Role and RoleBinding
122+
and grant the permission to get, list and watch Pod resources in the namespace
123+
`apiserversource-example` for the ApiServerSource.
124+
125+
Example ServiceAccount:
124126

125127
```yaml
126128
apiVersion: v1
127129
kind: ServiceAccount
128130
metadata:
129-
name: <service-account>
130-
namespace: <namespace>
131+
name: test-service-account
132+
namespace: apiserversource-example
131133
```
132134

135+
Example Role with permission to get, list and watch Pod resources:
136+
133137
```yaml
134138
apiVersion: rbac.authorization.k8s.io/v1
135139
kind: Role
136140
metadata:
137-
name: <role>
141+
name: test-role
138142
rules:
139143
- apiGroups:
140144
- ""
@@ -146,30 +150,34 @@ rules:
146150
- watch
147151
```
148152

153+
Example RoleBinding:
154+
149155
```yaml
150156
apiVersion: rbac.authorization.k8s.io/v1
151157
kind: RoleBinding
152158
metadata:
153-
name: <role-binding>
159+
name: test-role-binding
154160
roleRef:
155161
apiGroup: rbac.authorization.k8s.io
156162
kind: Role
157-
name: <role>
163+
name: test-role
158164
subjects:
159165
- kind: ServiceAccount
160-
name: <service-account>
161-
namespace: <namespace>
166+
name: test-service-account
167+
namespace: apiserversource-example
162168
```
163169

170+
Example ApiServerSource using `test-service-account`:
171+
164172
```yaml
165173
apiVersion: sources.knative.dev/v1
166174
kind: ApiServerSource
167175
metadata:
168-
name: <apiserversource>
169-
namespace: <namespace>
176+
name: test-apiserversource
177+
namespace: apiserversource-example
170178
spec:
171179
# ...
172-
serviceAccountName: <service-account>
180+
serviceAccountName: test-service-account
173181
...
174182
```
175183

@@ -202,54 +210,6 @@ spec:
202210
...
203211
```
204212

205-
### Sink parameter
206-
207-
Sink is a reference to an object that resolves to a URI to use as the sink.
208-
209-
A `sink` definition supports the following fields:
210-
211-
| Field | Description | Required or optional |
212-
|-------|-------------|----------------------|
213-
| `ref` | This points to an Addressable. | Required if _not_ using `uri` |
214-
| `ref.apiVersion` | API version of the referent. | Required if using `ref` |
215-
| [`ref.kind`][kubernetes-kinds] | Kind of the referent. | Required if using `ref` |
216-
| [`ref.namespace`][kubernetes-namespaces] | Namespace of the referent. If omitted this defaults to the object holding it. | Optional |
217-
| [`ref.name`][kubernetes-names] | Name of the referent. | Required if using `ref` |
218-
| `uri` | This can be an absolute URL with a non-empty scheme and non-empty host that points to the target or a relative URI. Relative URIs are resolved using the base URI retrieved from Ref. | Required if _not_ using `ref` |
219-
220-
!!! note
221-
At least one of `ref` or `uri` is required. If both are specified, `uri` is
222-
resolved into the URL from the Addressable `ref` result.
223-
224-
#### Example: Sink parameter
225-
226-
Given the following YAML, if `ref` resolves into
227-
`"http://mysink.default.svc.cluster.local"`, then `uri` is added to this
228-
resulting in `"http://mysink.default.svc.cluster.local/extra/path"`.
229-
230-
<!-- TODO we should have a page to point to describing the ref+uri destinations and the rules we use to resolve those and reuse the page. -->
231-
232-
```yaml
233-
apiVersion: sources.knative.dev/v1
234-
kind: ApiServerSource
235-
metadata:
236-
name: <apiserversource>
237-
namespace: <namespace>
238-
spec:
239-
...
240-
sink:
241-
ref:
242-
apiVersion: v1
243-
kind: Service
244-
namespace: default
245-
name: mysink
246-
uri: /extra/path
247-
```
248-
249-
!!! contract
250-
This results in the `K_SINK` environment variable being set on the sink container
251-
as `"http://mysink.default.svc.cluster.local/extra/path"`.
252-
253213

254214
### CloudEvent Overrides
255215

@@ -298,9 +258,5 @@ spec:
298258
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
299259
[label-selectors]:
300260
http://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
301-
[kubernetes-names]:
302-
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
303-
[kubernetes-namespaces]:
304-
https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
305261
[cloudevents-attribute-naming]:
306262
https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#attribute-naming-convention

docs/developer/eventing/sources/containersource/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Creating a ContainerSource object
22

3-
![API version v1](https://img.shields.io/badge/API_Version-v1-red?style=flat-square)
3+
![API version v1](https://img.shields.io/badge/API_Version-v1-green?style=flat-square)
44

55
This topic describes how to configure ContainerSource as an event source for
66
functions.
@@ -220,7 +220,7 @@ of the events that the ContainerSource sent to the `event-display` Service:
220220
}
221221
```
222222

223-
## Cleanup
223+
## Delete the ContainerSource object
224224

225225
To delete the ContainerSource object and all of the related resources in the
226226
namespace:

docs/developer/eventing/sources/containersource/reference.md

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ContainerSource reference
22

3+
![API version v1](https://img.shields.io/badge/API_Version-v1-green?style=flat-square)
4+
35
This topic provides reference information about the configurable fields for the
46
ContainerSource object.
57

@@ -14,59 +16,11 @@ A ContainerSource definition supports the following fields:
1416
| [`kind`][kubernetes-overview] | Identifies this resource object as a ContainerSource object. | Required |
1517
| [`metadata`][kubernetes-overview] | Specifies metadata that uniquely identifies the ContainerSource object. For example, a `name`. | Required |
1618
| [`spec`][kubernetes-overview] | Specifies the configuration information for this ContainerSource object. | Required |
17-
| [`spec.sink`](#sink-parameter) | A reference to an object that resolves to a URI to use as the sink. | Required |
19+
| [`spec.sink`](../../sinks/README.md#sink-as-a-parameter) | A reference to an object that resolves to a URI to use as the sink. | Required |
1820
| [`spec.template`](#template-parameter) | A `template` in the shape of `Deployment.spec.template` to be used for this ContainerSource. | Required |
1921
| [`spec.ceOverrides`](#cloudevent-overrides) | Defines overrides to control the output format and modifications to the event sent to the sink. | Optional |
2022

2123

22-
### Sink parameter
23-
24-
The `sink` parameter is a reference to an object that resolves to a URI to use as the sink.
25-
26-
A `sink` definition supports the following fields:
27-
28-
| Field | Description | Required or optional |
29-
|-------|-------------|----------------------|
30-
| `ref` | This points to an Addressable. | Required if _not_ using `uri` |
31-
| `ref.apiVersion` | API version of the referent. | Required if using `ref` |
32-
| [`ref.kind`][kubernetes-kinds] | Kind of the referent. | Required if using `ref` |
33-
| [`ref.name`][kubernetes-names] | Name of the referent. | Required if using `ref` |
34-
| [`ref.namespace`][kubernetes-namespaces] | Namespace of the referent. If omitted this defaults to the object holding it. | Optional |
35-
| `uri` | This can be an absolute URL with a non-empty scheme and non-empty host that points to the target or a relative URI. Relative URIs are resolved using the base URI retrieved from Ref. | Required if _not_ using `ref` |
36-
37-
!!! note
38-
At least one of `ref` or `uri` is required. If both are specified, `uri` is
39-
resolved into the URL from the Addressable `ref` result.
40-
41-
#### Example: sink parameter
42-
43-
Given the following YAML, if `ref` resolves into
44-
`"http://mysink.default.svc.cluster.local"`, then `uri` is added to this
45-
resulting in `"http://mysink.default.svc.cluster.local/extra/path"`.
46-
47-
<!-- TODO we should have a page to point to describing the ref+uri destinations and the rules we use to resolve those and reuse the page. -->
48-
49-
```yaml
50-
apiVersion: sources.knative.dev/v1
51-
kind: ContainerSource
52-
metadata:
53-
name: test-heartbeats
54-
spec:
55-
...
56-
sink:
57-
ref:
58-
apiVersion: v1
59-
kind: Service
60-
namespace: default
61-
name: mysink
62-
uri: /extra/path
63-
```
64-
65-
!!! contract
66-
This results in the `K_SINK` environment variable being set as
67-
`"http://mysink.default.svc.cluster.local/extra/path"`. <!-- unsure about this -->
68-
69-
7024
### Template parameter
7125

7226
This is a `template` in the shape of `Deployment.spec.template` to use for the ContainerSource.
@@ -139,11 +93,5 @@ spec:
13993

14094
[kubernetes-overview]:
14195
https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/#required-fields
142-
[kubernetes-kinds]:
143-
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
144-
[kubernetes-names]:
145-
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
146-
[kubernetes-namespaces]:
147-
https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
14896
[cloudevents-attribute-naming]:
14997
https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#attribute-naming-convention

0 commit comments

Comments
 (0)