Skip to content

Commit d7850dd

Browse files
chore: Describe RBAC rules, remove unnecessary rules (#1020)
* chore: Describe RBAC rules, remove unnecessary rules * chore: Update changelog * Apply suggestions from code review Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * chore: Add missing rule comment * chore: Remove the get for customresourcedefinitions for the operator clusterrole It is not needed for CRD maintenance nor startup condition * chore: Remove the configmaps/secrets/serviceaccounts get rule for the product clusterrole Any necessary configmaps/secrets would be mounted. The product pod doesn't communicate with the Kubernetes API * fix: customresourcedefinitions list/watch is always required for startup condition * chore: Simplify the rule comments * chore: Remove the events.k8s.io rule from the product ClusterRole The operator manages events * chore: Split the roles.yaml into separate files for clusterrole-operator.yaml and clusterrole-product.yaml * Update deploy/helm/zookeeper-operator/templates/clusterrole-operator.yaml Co-authored-by: Techassi <sascha.lautenschlaeger@stackable.tech> --------- Co-authored-by: Techassi <sascha.lautenschlaeger@stackable.tech>
1 parent 82de264 commit d7850dd

3 files changed

Lines changed: 68 additions & 67 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Changed
8+
9+
- Document Helm deployed RBAC permissions and remove unnecessary permissions ([#1020]).
10+
11+
[#1020]: https://github.com/stackabletech/zookeeper-operator/pull/1020
12+
713
## [26.3.0] - 2026-03-16
814

915
## [26.3.0-rc1] - 2026-03-16

deploy/helm/zookeeper-operator/templates/roles.yaml renamed to deploy/helm/zookeeper-operator/templates/clusterrole-operator.yaml

Lines changed: 41 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,42 @@ metadata:
66
labels:
77
{{- include "operator.labels" . | nindent 4 }}
88
rules:
9-
- apiGroups:
10-
- ""
11-
resources:
12-
- nodes
13-
verbs:
14-
- list
15-
- watch
169
# For automatic cluster domain detection
1710
- apiGroups:
1811
- ""
1912
resources:
2013
- nodes/proxy
2114
verbs:
2215
- get
16+
# Manage core workload resources created per ZookeeperCluster.
17+
# All resources are applied via SSA (create + patch) and tracked for
18+
# orphan cleanup (list + delete).
2319
- apiGroups:
2420
- ""
2521
resources:
26-
- pods
2722
- configmaps
28-
- secrets
2923
- services
30-
- endpoints
31-
- serviceaccounts
3224
verbs:
3325
- create
3426
- delete
3527
- get
3628
- list
3729
- patch
38-
- update
3930
- watch
31+
# ServiceAccount created per ZookeeperCluster for workload pod identity.
32+
# Applied via SSA and tracked for orphan cleanup.
33+
- apiGroups:
34+
- ""
35+
resources:
36+
- serviceaccounts
37+
verbs:
38+
- create
39+
- delete
40+
- get
41+
- list
42+
- patch
43+
# RoleBinding created per ZookeeperCluster to bind the product ClusterRole to the workload
44+
# ServiceAccount. Applied via SSA and tracked for orphan cleanup.
4045
- apiGroups:
4146
- rbac.authorization.k8s.io
4247
resources:
@@ -47,8 +52,7 @@ rules:
4752
- get
4853
- list
4954
- patch
50-
- update
51-
- watch
55+
# Required to bind the product ClusterRole to the per-cluster ServiceAccount.
5256
- apiGroups:
5357
- rbac.authorization.k8s.io
5458
resources:
@@ -57,30 +61,20 @@ rules:
5761
- bind
5862
resourceNames:
5963
- {{ include "operator.name" . }}-clusterrole
64+
# StatefulSet created per role group. Applied via SSA, tracked for orphan cleanup,
65+
# and owned by the controller.
6066
- apiGroups:
6167
- apps
6268
resources:
6369
- statefulsets
64-
verbs:
65-
- get
66-
- create
67-
- delete
68-
- list
69-
- patch
70-
- update
71-
- watch
72-
- apiGroups:
73-
- batch
74-
resources:
75-
- jobs
7670
verbs:
7771
- create
7872
- delete
7973
- get
8074
- list
8175
- patch
82-
- update
8376
- watch
77+
# PodDisruptionBudget created per role. Applied via SSA and tracked for orphan cleanup.
8478
- apiGroups:
8579
- policy
8680
resources:
@@ -91,23 +85,23 @@ rules:
9185
- get
9286
- list
9387
- patch
94-
- update
95-
- watch
88+
# Required for maintaining the CRDs (including the conversion webhook certificate).
89+
# Also required for the startup condition check.
9690
- apiGroups:
9791
- apiextensions.k8s.io
9892
resources:
9993
- customresourcedefinitions
10094
verbs:
101-
- get
10295
# Required to maintain the CRD. The operator needs to do this, as it needs to enter e.g. it's
10396
# generated certificate in the conversion webhook.
10497
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
10598
- create
10699
- patch
100+
{{- end }}
107101
# Required for startup condition
108102
- list
109103
- watch
110-
{{- end }}
104+
# Read AuthenticationClass configuration referenced in the ZookeeperCluster spec.
111105
- apiGroups:
112106
- authentication.stackable.tech
113107
resources:
@@ -116,71 +110,51 @@ rules:
116110
- get
117111
- list
118112
- watch
113+
# Required to report reconciliation results and warnings.
119114
- apiGroups:
120115
- events.k8s.io
121116
resources:
122117
- events
123118
verbs:
124119
- create
125120
- patch
121+
# Listener created per role group for external access. Applied via SSA and tracked for
122+
# orphan cleanup.
126123
- apiGroups:
127124
- listeners.stackable.tech
128125
resources:
129126
- listeners
130127
verbs:
128+
- create
129+
- delete
131130
- get
132131
- list
133-
- watch
134132
- patch
135-
- create
136-
- delete
133+
# Primary CRD: watched and read during reconciliation.
137134
- apiGroups:
138135
- {{ include "operator.name" . }}.stackable.tech
139136
resources:
140137
- {{ include "operator.name" . }}clusters
141-
- {{ include "operator.name" . }}znodes
142138
verbs:
143139
- get
144140
- list
145-
- patch
146141
- watch
142+
# ZookeeperZnode CRD: watched and read during reconciliation.
143+
# Patch is required to manage a finalizer for znode cleanup before deletion.
147144
- apiGroups:
148145
- {{ include "operator.name" . }}.stackable.tech
149146
resources:
150-
- {{ include "operator.name" . }}clusters/status
151-
- {{ include "operator.name" . }}znodes/status
152-
verbs:
153-
- patch
154-
---
155-
apiVersion: rbac.authorization.k8s.io/v1
156-
kind: ClusterRole
157-
metadata:
158-
name: {{ include "operator.name" . }}-clusterrole
159-
labels:
160-
{{- include "operator.labels" . | nindent 4 }}
161-
rules:
162-
- apiGroups:
163-
- ""
164-
resources:
165-
- configmaps
166-
- secrets
167-
- serviceaccounts
147+
- {{ include "operator.name" . }}znodes
168148
verbs:
169149
- get
170-
- apiGroups:
171-
- events.k8s.io
172-
resources:
173-
- events
174-
verbs:
175-
- create
150+
- list
176151
- patch
177-
{{ if .Capabilities.APIVersions.Has "security.openshift.io/v1" }}
152+
- watch
153+
# Status subresource: updated at the end of every reconciliation.
178154
- apiGroups:
179-
- security.openshift.io
155+
- {{ include "operator.name" . }}.stackable.tech
180156
resources:
181-
- securitycontextconstraints
182-
resourceNames:
183-
- nonroot-v2
157+
- {{ include "operator.name" . }}clusters/status
158+
- {{ include "operator.name" . }}znodes/status
184159
verbs:
185-
- use
186-
{{ end }}
160+
- patch
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# Product ClusterRole: bound (via per ZookeeperCluster RoleBinding) to the ServiceAccount that
3+
# ZooKeeper workload pods run as.
4+
apiVersion: rbac.authorization.k8s.io/v1
5+
kind: ClusterRole
6+
metadata:
7+
name: {{ include "operator.name" . }}-clusterrole
8+
labels:
9+
{{- include "operator.labels" . | nindent 4 }}
10+
rules:
11+
{{ if .Capabilities.APIVersions.Has "security.openshift.io/v1" }}
12+
# Required on OpenShift to allow ZooKeeper pods to run as a non-root user.
13+
- apiGroups:
14+
- security.openshift.io
15+
resources:
16+
- securitycontextconstraints
17+
resourceNames:
18+
- nonroot-v2
19+
verbs:
20+
- use
21+
{{ end }}

0 commit comments

Comments
 (0)