Skip to content

Commit bd8e894

Browse files
authored
Merge pull request #8608 from zalando-incubator/update-role-sync-controller-rbac
add appropriate RBAC for the role-sync-controller
2 parents f2b4861 + fd4b3c4 commit bd8e894

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

cluster/manifests/deletions.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ post_apply:
313313
- name: role-sync-controller
314314
kind: CronJob
315315
namespace: kube-system
316+
- name: role-sync-controller
317+
kind: ClusterRole
316318
- name: role-sync-controller
317319
kind: ClusterRoleBinding
318320
- name: role-sync-controller

cluster/manifests/role-sync-controller/rbac.yaml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
{{ if eq .Cluster.ConfigItems.role_sync_controller_enabled "true" }}
22
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: role-sync-controller
6+
labels:
7+
application: kubernetes
8+
component: role-sync-controller
9+
rules:
10+
# Allow the controller to list namespaces
11+
- apiGroups:
12+
- ""
13+
resources:
14+
- "namespaces"
15+
verbs:
16+
- "list"
17+
# Allow the controller to manage Roles and Rolebindings
18+
- apiGroups:
19+
- rbac.authorization.k8s.io
20+
resources:
21+
- roles
22+
- rolebindings
23+
verbs:
24+
- "get"
25+
- "create"
26+
- "update"
27+
# Allow the controller to manage roles based on reading Secrets
28+
- apiGroups:
29+
- ""
30+
resources:
31+
- secrets
32+
verbs:
33+
- "get"
34+
- "list"
35+
- "watch"
36+
---
37+
apiVersion: rbac.authorization.k8s.io/v1
338
kind: ClusterRoleBinding
439
metadata:
540
name: role-sync-controller
@@ -9,7 +44,7 @@ metadata:
944
roleRef:
1045
apiGroup: rbac.authorization.k8s.io
1146
kind: ClusterRole
12-
name: poweruser
47+
name: role-sync-controller
1348
subjects:
1449
- kind: ServiceAccount
1550
name: role-sync-controller

test/e2e/authorization.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ var _ = g.Describe("Authorization [RBAC] [Zalando]", func() {
185185

186186
g.It("should allow read access to Secrets in namespaces other than kube-system and visibility", func() {
187187
tc.data.resources = []string{"secrets"}
188-
tc.data.namespaces = []string{"default", "teapot"}
188+
// The namespace must exist for the test case to pass, otherwise access
189+
// remains undecided.
190+
tc.data.namespaces = []string{"default"}
189191
tc.data.verbs = readOperations
190192
tc.run(context.TODO(), cs, true)
191193
gomega.Expect(tc.output.passed).To(gomega.BeTrue(), tc.output.String())

0 commit comments

Comments
 (0)