Skip to content

Commit d74dabd

Browse files
fix: add events.k8s.io to the Helm chart manager ClusterRole (#351)
Signed-off-by: tejassinghbhati <tejassinghbhati077@gmail.com>
1 parent 196e120 commit d74dabd

2 files changed

Lines changed: 73 additions & 1 deletion

File tree

charts/nrr-controller/templates/rbac.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ metadata:
3737
labels:
3838
{{- include "nrr-controller.labels" . | nindent 4 }}
3939
rules:
40-
- apiGroups: [""]
40+
- apiGroups: ["", "events.k8s.io"]
4141
resources: ["events"]
4242
verbs: ["create", "patch"]
4343
- apiGroups: [""]
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
suite: Test Node Readiness Controller Manager RBAC
2+
3+
templates:
4+
- "*.yaml"
5+
6+
release:
7+
name: nrr-controller
8+
9+
tests:
10+
- it: grants events on both the core and events.k8s.io groups
11+
template: templates/rbac.yaml
12+
documentSelector:
13+
path: metadata.name
14+
value: nrr-controller-manager-role
15+
asserts:
16+
- isKind:
17+
of: ClusterRole
18+
# The controller records taint events via k8s.io/client-go/tools/events,
19+
# which writes to events.k8s.io/v1. Granting only the core group makes
20+
# every TaintAdded, TaintRemoved and TaintAdopted write forbidden.
21+
- contains:
22+
path: rules
23+
content:
24+
apiGroups: ["", "events.k8s.io"]
25+
resources: ["events"]
26+
verbs: ["create", "patch"]
27+
28+
- it: grants the node and rule permissions the controller needs
29+
template: templates/rbac.yaml
30+
documentSelector:
31+
path: metadata.name
32+
value: nrr-controller-manager-role
33+
asserts:
34+
- contains:
35+
path: rules
36+
content:
37+
apiGroups: [""]
38+
resources: ["nodes"]
39+
verbs: ["get", "list", "patch", "update", "watch"]
40+
- contains:
41+
path: rules
42+
content:
43+
apiGroups: [""]
44+
resources: ["nodes/status"]
45+
verbs: ["get"]
46+
- contains:
47+
path: rules
48+
content:
49+
apiGroups: ["readiness.node.x-k8s.io"]
50+
resources: ["nodereadinessrules"]
51+
verbs: ["get", "list", "patch", "update", "watch"]
52+
- contains:
53+
path: rules
54+
content:
55+
apiGroups: ["readiness.node.x-k8s.io"]
56+
resources: ["nodereadinessrules/finalizers"]
57+
verbs: ["update"]
58+
- contains:
59+
path: rules
60+
content:
61+
apiGroups: ["readiness.node.x-k8s.io"]
62+
resources: ["nodereadinessrules/status"]
63+
verbs: ["get", "patch", "update"]
64+
65+
- it: omits rbac resources when rbac.create is disabled
66+
template: templates/rbac.yaml
67+
set:
68+
rbac:
69+
create: false
70+
asserts:
71+
- hasDocuments:
72+
count: 0

0 commit comments

Comments
 (0)