Skip to content

Commit 8580775

Browse files
author
Mengqi Yu
committed
🐛 grant manager permissions to create events
controller-manager needs permissions to create events when doing leader election.
1 parent a5a1bf2 commit 8580775

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

docs/book/src/cronjob-tutorial/testdata/project/config/rbac/kustomization.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
resources:
22
- role.yaml
33
- role_binding.yaml
4+
- leader_election_role.yaml
5+
- leader_election_role_binding.yaml
46
# Comment the following 3 lines if you want to disable
57
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
68
# which protects your /metrics endpoint.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# permissions to do leader election.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: Role
4+
metadata:
5+
name: leader-election-role
6+
rules:
7+
- apiGroups:
8+
- ""
9+
resources:
10+
- configmaps
11+
verbs:
12+
- get
13+
- list
14+
- watch
15+
- create
16+
- update
17+
- patch
18+
- delete
19+
- apiGroups:
20+
- ""
21+
resources:
22+
- configmaps/status
23+
verbs:
24+
- get
25+
- update
26+
- patch
27+
- apiGroups:
28+
- ""
29+
resources:
30+
- events
31+
verbs:
32+
- create
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
name: leader-election-rolebinding
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: Role
8+
name: leader-election-role
9+
subjects:
10+
- kind: ServiceAccount
11+
name: default
12+
namespace: system

pkg/scaffold/v2/leaderelectionrole.go

+6
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,10 @@ rules:
6464
- get
6565
- update
6666
- patch
67+
- apiGroups:
68+
- ""
69+
resources:
70+
- events
71+
verbs:
72+
- create
6773
`

testdata/project-v2/config/rbac/leader_election_role.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ rules:
2424
- get
2525
- update
2626
- patch
27+
- apiGroups:
28+
- ""
29+
resources:
30+
- events
31+
verbs:
32+
- create

0 commit comments

Comments
 (0)