You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
📚 Sync docs from alaudadevops/tektoncd-operator on b908cd738c107ea344fbee70e7cfc0f88df5c71a
Source: docs: update eventlistener user guide (#792)
Author: Yukun Sun
Ref: refs/heads/main
Commit: b908cd738c107ea344fbee70e7cfc0f88df5c71a
This commit automatically syncs documentation changes from the source-docs repository.
🔗 View source commit: https://github.com/alaudadevops/tektoncd-operator/commit/b908cd738c107ea344fbee70e7cfc0f88df5c71a
🤖 Synced on 2025-11-17 07:19:22 UTC
- **Default ServiceAccount**: If `spec.serviceAccountName` is not specified, EventListener will use the default ServiceAccount in the namespace. The default ServiceAccount has namespace-scoped permissions only and is suitable for EventListeners that only need to handle triggers within the same namespace.
90
+
- **Default ServiceAccount (`triggers-default-sa`)**: If `spec.serviceAccountName` is not specified, EventListener will automatically use the `triggers-default-sa` ServiceAccount in the namespace. This ServiceAccount is automatically granted the necessary namespace-scoped permissions required for EventListeners to handle triggers within the same namespace. The permissions are automatically bound to the namespace where the ServiceAccount exists.
91
91
- **Custom ServiceAccount**: When you need to handle triggers across multiple namespaces (e.g., when `namespaceSelector` is configured), you must specify a custom ServiceAccount with cluster-scoped permissions. Ensure that the specified ServiceAccount is configured with the corresponding permissions (see [Permission Guidelines](#permission-guidelines) below).
92
92
2. **Interceptor Validation**: Use CEL interceptors for event validation.
#### Default ServiceAccount vs Custom ServiceAccount
98
98
99
-
- **Default ServiceAccount**: When `spec.serviceAccountName` is not specified, EventListener uses the default ServiceAccount. The default ServiceAccount only has namespace-scoped permissions, which is sufficient for EventListeners that handle triggers within the same namespace only.
99
+
- **Default ServiceAccount (`triggers-default-sa`)**: When `spec.serviceAccountName` is not specified, EventListener automatically uses the `triggers-default-sa` ServiceAccount in the namespace. This ServiceAccount is automatically granted the necessary namespace-scoped permissions required for EventListeners to handle triggers within the same namespace. The permissions are automatically bound to the namespace where the ServiceAccount exists, so you don't need to manually configure Role or RoleBinding.
100
100
101
-
- **Custom ServiceAccount with Cluster Permissions**: When you configure `namespaceSelector` to listen to triggers from multiple namespaces (including `'*'` for all namespaces), you must specify a custom ServiceAccount with cluster-scoped permissions. The default ServiceAccount does not have the necessary cluster-scoped permissions to access resources across namespaces.
101
+
- **Custom ServiceAccount with Cluster Permissions**: When you configure `namespaceSelector` to listen to triggers from multiple namespaces (including `'*'` for all namespaces), you must specify a custom ServiceAccount with cluster-scoped permissions. The `triggers-default-sa` ServiceAccount only has namespace-scoped permissions and does not have the necessary cluster-scoped permissions to access resources across namespaces.
102
102
103
103
#### Required Permissions
104
104
@@ -159,6 +159,117 @@ rules:
159
159
160
160
Deploying the EventListener needs to be planned according to the scale and the actual network situation of the environment, as described below on how to configure differently based on planning:
161
161
162
+
### EventListener Trigger Configuration Scenarios
163
+
164
+
EventListener supports three different scenarios for configuring triggers, each suitable for different use cases:
165
+
166
+
#### 1. Namespace-Level EventListener
167
+
168
+
A namespace-level EventListener binds to specific triggers within the same namespace by explicitly configuring the `triggers` field in the EventListener spec. This is the simplest scenario and is suitable for single-namespace deployments.
169
+
170
+
**Use Cases and Recommendations:**
171
+
172
+
- **Use Cases**:
173
+
- Independent deployment and management for a single project or team
174
+
- Requires explicit resource isolation and permission control
175
+
- Teams have in-depth understanding of EventListener configuration and need fine-grained control over each trigger
176
+
- Different namespaces require different EventListener configurations or resource limits
177
+
- High requirements for performance and fault isolation
178
+
179
+
- **Recommended For**:
180
+
- Experienced DevOps teams or scenarios requiring high customization
181
+
- When different projects need different EventListener configurations, resource quotas, or security policies
182
+
- Multi-tenant environments requiring complete isolation between tenants
183
+
- When different namespaces need different replica counts, resource limits, or network policies
184
+
185
+
**Example Configuration:**
186
+
187
+
```yaml
188
+
spec:
189
+
# serviceAccountName is optional, defaults to triggers-default-sa
190
+
triggers:
191
+
- name: trigger-1
192
+
bindings:
193
+
- ref: gitlab-push
194
+
kind: ClusterTriggerBinding
195
+
template:
196
+
ref: pipeline-template
197
+
- name: trigger-2
198
+
bindings:
199
+
- ref: github-pullrequest
200
+
kind: ClusterTriggerBinding
201
+
template:
202
+
ref: pipeline-template
203
+
```
204
+
205
+
#### 2. Project-Level EventListener
206
+
207
+
A project-level EventListener uses `namespaceSelector` to bind to triggers across multiple specified namespaces. This is suitable for managing triggers across a set of related namespaces (e.g., a project or team).
208
+
209
+
**Use Cases and Recommendations:**
210
+
211
+
- **Use Cases**:
212
+
- Multiple related projects or namespaces need to share the same EventListener
213
+
- Unified event handling at the project group or department level
214
+
- Need to share resources across multiple namespaces without covering the entire cluster
215
+
- Some performance isolation requirements, but can accept resource sharing within the project group
216
+
217
+
- **Recommended For**:
218
+
- Medium-sized teams or project groups that need unified trigger management across multiple related namespaces
219
+
- When multiple projects use similar configurations and resource requirements, reducing operational costs
220
+
- When centralized management of Webhook events for a group of related projects is needed
221
+
- Teams with some understanding of EventListener who can configure and manage cross-namespace permissions
222
+
223
+
**Example Configuration:**
224
+
225
+
```yaml
226
+
spec:
227
+
serviceAccountName: eventlistener # Custom SA with cluster permissions
228
+
namespaceSelector:
229
+
matchNames:
230
+
- project-a
231
+
- project-b
232
+
- project-c
233
+
```
234
+
235
+
#### 3. Global-Level EventListener
236
+
237
+
A global-level EventListener uses `namespaceSelector` with a wildcard (`'*'`) to bind to triggers from all namespaces in the cluster. This is suitable for centralized event handling across the entire cluster.
238
+
239
+
**Use Cases and Recommendations:**
240
+
241
+
- **Use Cases**:
242
+
- Cluster-wide unified event processing and management
243
+
- Users have no strict requirements for performance isolation and can accept resource sharing
244
+
- One-time configuration enables all users to use it out-of-the-box without separate configuration in each namespace
245
+
- Users don't need in-depth knowledge of EventListener, managed uniformly by the platform
246
+
- Small to medium-sized clusters with relatively controllable event volumes
247
+
248
+
- **Recommended For**:
249
+
- Platform scenarios where platform administrators configure and manage uniformly
250
+
- When cluster scale is small and all users need to use the same EventListener configuration
251
+
- Simplifying user workflows and reducing learning costs and configuration complexity
252
+
- Centralized operational management for unified monitoring and troubleshooting
253
+
- Note: In large-scale clusters or high-concurrency scenarios, performance impact and fault isolation should be considered
254
+
255
+
**Example Configuration:**
256
+
257
+
```yaml
258
+
spec:
259
+
serviceAccountName: eventlistener # Custom SA with cluster permissions
260
+
namespaceSelector:
261
+
matchNames:
262
+
- '*' # Wildcard for all namespaces
263
+
```
264
+
265
+
**Comparison Table:**
266
+
267
+
| Scenario | Namespace Scope | ServiceAccount | Configuration Complexity | Use Case |
| Namespace-Level | Single namespace | `triggers-default-sa` (auto) | Simple | Single project/team |
270
+
| Project-Level | Multiple specified namespaces | Custom SA (cluster permissions) | Moderate | Multiple related projects |
271
+
| Global-Level | All namespaces (`*`) | Custom SA (cluster permissions) | Complex | Cluster-wide management |
272
+
162
273
### Scale
163
274
164
275
In different planning scenarios, different configurations can be used to meet varying requirements.
@@ -196,51 +307,15 @@ Depending on the priority of the environment and the available network resources
196
307
kubectl create namespace tekton-webhooks
197
308
```
198
309
199
-
### Create EventListener
310
+
### Create ClusterRole and ServiceAccount and Set Permissions
200
311
201
-
Save the following YAML as `eventlistener.yaml`.
312
+
- **Default ServiceAccount (`triggers-default-sa`)**: When `spec.serviceAccountName` is not specified, EventListener automatically uses the `triggers-default-sa` ServiceAccount in the namespace. This ServiceAccount is automatically granted the necessary namespace-scoped permissions required for EventListeners to handle triggers within the same namespace. The permissions are automatically bound to the namespace where the ServiceAccount exists, so you don't need to manually configure Role or RoleBinding.
202
313
203
-
:::info
204
-
**ServiceAccount Selection**:
205
-
- If you only need to handle triggers within the same namespace, you can omit `spec.serviceAccountName` to use the default ServiceAccount.
206
-
- Since this example uses `namespaceSelector` with `'*'` to listen to triggers from all namespaces, a custom ServiceAccount with cluster-scoped permissions is required. Therefore, `serviceAccountName: "eventlistener"` is specified here.
207
-
:::
314
+
- **Custom ServiceAccount with Cluster Permissions**: When you configure `namespaceSelector` to listen to triggers from multiple namespaces (including `'*'` for all namespaces), you must specify a custom ServiceAccount with cluster-scoped permissions. The `triggers-default-sa` ServiceAccount only has namespace-scoped permissions and does not have the necessary cluster-scoped permissions to access resources across namespaces.
208
315
209
-
```yaml
210
-
apiVersion: triggers.tekton.dev/v1beta1
211
-
kind: EventListener
212
-
metadata:
213
-
name: eventlistener
214
-
namespace: tekton-webhooks
215
-
labels:
216
-
el.tekton.dev/namespaces: all
217
-
el.tekton.dev/size: small
218
-
spec:
219
-
serviceAccountName: "eventlistener"# Required: Custom SA with cluster permissions needed for namespaceSelector
220
-
# Listen to triggers from all NS
221
-
namespaceSelector:
222
-
matchNames:
223
-
- '*'
224
-
# Declare Kubernetes resource, default is Deployment
225
-
resources:
226
-
kubernetesResource:
227
-
serviceType: ClusterIP # ClusterIP service type
228
-
servicePort: 80# Service port (container port)
229
-
replicas: 2# Replicas
230
-
spec: # Deployment spec
231
-
template:
232
-
metadata:
233
-
labels:
234
-
el.tekton.dev/namespaces: all
235
-
el.tekton.dev/size: small
236
-
spec: {}
237
-
```
238
-
239
-
```bash
240
-
kubectl apply -f eventlistener.yaml
241
-
```
242
-
243
-
### Create ClusterRole
316
+
:::warning
317
+
**Required for namespaceSelector**: The following steps are only required when using `namespaceSelector` to listen to triggers across multiple namespaces. If your EventListener only handles triggers within the same namespace, you can skip these steps and use the default `triggers-default-sa` ServiceAccount, which will automatically have the required permissions.
318
+
:::
244
319
245
320
The following YAML is for `eventlistener-role.yaml`.
246
321
@@ -278,19 +353,57 @@ Depending on the priority of the environment and the available network resources
278
353
kubectl apply -f eventlistener-role.yaml
279
354
```
280
355
281
-
### Create ServiceAccount and Set Permissions
282
-
283
-
:::warning
284
-
**Required for namespaceSelector**: The following steps are only required when using `namespaceSelector` to listen to triggers across multiple namespaces. If your EventListener only handles triggers within the same namespace, you can skip these steps and use the default ServiceAccount.
285
-
:::
286
-
287
356
Create a binding using the ClusterRole and ServiceAccount above.
- If you only need to handle triggers within the same namespace, you can omit `spec.serviceAccountName` to use the default `triggers-default-sa` ServiceAccount, which will automatically have the required namespace-scoped permissions.
370
+
- Since this example uses `namespaceSelector` with `'*'` to listen to triggers from all namespaces, a custom ServiceAccount with cluster-scoped permissions is required. Therefore, `serviceAccountName: "eventlistener"` is specified here.
371
+
:::
372
+
373
+
```yaml
374
+
apiVersion: triggers.tekton.dev/v1beta1
375
+
kind: EventListener
376
+
metadata:
377
+
name: eventlistener
378
+
namespace: tekton-webhooks
379
+
labels:
380
+
el.tekton.dev/namespaces: all
381
+
el.tekton.dev/size: small
382
+
spec:
383
+
serviceAccountName: "eventlistener"# Required: Custom SA with cluster permissions needed for namespaceSelector
384
+
# Listen to triggers from all NS
385
+
namespaceSelector:
386
+
matchNames:
387
+
- '*'
388
+
# Declare Kubernetes resource, default is Deployment
389
+
resources:
390
+
kubernetesResource:
391
+
serviceType: ClusterIP # ClusterIP service type
392
+
servicePort: 80# Service port (container port)
393
+
replicas: 2# Replicas
394
+
spec: # Deployment spec
395
+
template:
396
+
metadata:
397
+
labels:
398
+
el.tekton.dev/namespaces: all
399
+
el.tekton.dev/size: small
400
+
spec: {}
401
+
```
402
+
403
+
```bash
404
+
kubectl apply -f eventlistener.yaml
405
+
```
406
+
294
407
### Create Ingress and TLS Secrets
295
408
296
409
::: info
@@ -378,9 +491,10 @@ Depending on the priority of the environment and the available network resources
378
491
379
492
2.**Permission Issues**
380
493
- Confirm ServiceAccount permissions.
381
-
- Check Role and RoleBinding.
494
+
- If using the default `triggers-default-sa` ServiceAccount, verify that it exists in the namespace and has been automatically granted the required permissions.
495
+
- If using a custom ServiceAccount, check Role and RoleBinding configurations.
382
496
- Verify namespace access permissions.
383
-
- If using `namespaceSelector` to listen across namespaces, ensure you're using a custom ServiceAccount with cluster-scoped permissions. The default ServiceAccount only has namespace-scoped permissions.
497
+
- If using `namespaceSelector` to listen across namespaces, ensure you're using a custom ServiceAccount with cluster-scoped permissions. The `triggers-default-sa` ServiceAccount only has namespace-scoped permissions.
0 commit comments