Skip to content

Commit

Permalink
Fix example SA permissions
Browse files Browse the repository at this point in the history
The service account used for examples had permissions for all namespaced
Triggers resources but not `clustertriggerbindings`. With the switch to using
listers instead of making direct API calls this means that the EL will keep
printing out error log messages about not being able to fetch
clustertriggerbindings. To fix this, I added updated the SA with the right
ClusterRole and Binding.

In addition, some of the examples were using their own roles/SAs/bindings.
Instead of updating those, I created a single `rbac.yaml` file and added
symlinks to it from the examples.

Fixes #846

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
  • Loading branch information
dibyom authored and tekton-robot committed Dec 2, 2020
1 parent c51a605 commit 6d9e16f
Show file tree
Hide file tree
Showing 31 changed files with 77 additions and 512 deletions.
35 changes: 4 additions & 31 deletions docs/eventlisteners.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,38 +80,11 @@ the following fields:
### ServiceAccountName

The `serviceAccountName` field is required. The ServiceAccount that the
EventListener sink uses to create the Tekton resources. The ServiceAccount needs
a role with the following rules:
EventListener sink uses to create the Tekton resources.
The ServiceAccount needs a Role that with "get", "list", and "watch" verbs for each Triggers resource as well as a ClusterRole with read access to ClusterTriggerBindings. In addition, it needs to have "create"
permissions on the Pipeline resources it needs to create. See a working example at [../examples/rbac.yaml](../examples/rbac.yaml).

<!-- FILE: examples/role-resources/triggerbinding-roles/role.yaml -->
```YAML
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tekton-triggers-example-minimal
rules:
# Permissions for every EventListener deployment to function
- apiGroups: ["triggers.tekton.dev"]
resources: ["eventlisteners", "triggerbindings", "triggertemplates", "triggers"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
# secrets are only needed for GitHub/GitLab interceptors
resources: ["configmaps", "secrets"]
verbs: ["get", "list", "watch"]
# Permissions to create resources in associated TriggerTemplates
- apiGroups: ["tekton.dev"]
resources: ["pipelineruns", "pipelineresources", "taskruns"]
verbs: ["create"]
- apiGroups: [""]
resources: ["serviceaccounts"]
verbs: ["impersonate"]
```


If your EventListener is using
[`ClusterTriggerBindings`](./clustertriggerbindings.md), you'll need a
ServiceAccount with a
[ClusterRole instead](../examples/role-resources/clustertriggerbinding-roles/clusterrole.yaml).
If your EventListener is using `namespaceSelectors`, the ServiceAccount will require a Cluster role to have read permissions for all Triggers resources across the cluster.

### Triggers

Expand Down
1 change: 1 addition & 0 deletions examples/bitbucket/rbac.yaml
62 changes: 0 additions & 62 deletions examples/bitbucket/role.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions examples/cron/binding.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/cron/eventlistener.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: EventListener
metadata:
name: cron-listener
spec:
serviceAccountName: tekton-triggers-cron-sa
serviceAccountName: tekton-triggers-example-sa
triggers:
- name: cron-trig
bindings:
Expand Down
1 change: 1 addition & 0 deletions examples/cron/rbac.yaml
30 changes: 0 additions & 30 deletions examples/cron/role.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions examples/cron/secret.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions examples/cron/serviceaccount.yaml

This file was deleted.

1 change: 1 addition & 0 deletions examples/eventlistener-tls-connection/rbac.yaml
62 changes: 0 additions & 62 deletions examples/eventlistener-tls-connection/role.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions examples/eventlistener-tls-connection/secret.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/github/github-eventlistener-interceptor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
spec:
template:
spec:
serviceAccountName: tekton-triggers-github-sa
serviceAccountName: tekton-triggers-example-sa
containers:
- resources:
requests:
Expand Down
1 change: 1 addition & 0 deletions examples/github/rbac.yaml
62 changes: 0 additions & 62 deletions examples/github/role.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions examples/gitlab/binding.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/gitlab/gitlab-push-listener.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: EventListener
metadata:
name: gitlab-listener
spec:
serviceAccountName: tekton-triggers-gitlab-sa
serviceAccountName: tekton-triggers-example-sa
triggers:
- name: gitlab-push-events-trigger
interceptors:
Expand Down
1 change: 1 addition & 0 deletions examples/gitlab/rbac.yaml
Loading

0 comments on commit 6d9e16f

Please sign in to comment.