Skip to content

Commit c06b205

Browse files
committed
chore: Describe RBAC rules, remove unnecessary rules
1 parent 9d4ecda commit c06b205

1 file changed

Lines changed: 36 additions & 27 deletions

File tree

deploy/helm/kafka-operator/templates/roles.yaml

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,44 @@ metadata:
66
labels:
77
{{- include "operator.labels" . | nindent 4 }}
88
rules:
9+
# For automatic cluster domain detection (list nodes to infer the cluster DNS domain)
910
- apiGroups:
1011
- ""
1112
resources:
1213
- nodes
1314
verbs:
1415
- list
1516
- watch
16-
# For automatic cluster domain detection
17+
# For automatic cluster domain detection (probe node proxy to read DNS config)
1718
- apiGroups:
1819
- ""
1920
resources:
2021
- nodes/proxy
2122
verbs:
2223
- get
24+
# Manage core namespaced resources created per KafkaCluster.
25+
# All resources are applied via Server-Side Apply (create + patch) and tracked for
26+
# orphan cleanup (list + delete). The ReconciliationPaused strategy calls get instead
27+
# of apply_patch, so get is also needed. All three are watched by the controller via
28+
# .owns(), so watch is required.
29+
# - configmaps: per-rolegroup configuration, and the discovery ConfigMap
30+
# - services: per-rolegroup headless and metrics services
31+
# - serviceaccounts: one per KafkaCluster, created by build_rbac_resources()
2332
- apiGroups:
2433
- ""
2534
resources:
26-
- pods
2735
- configmaps
28-
- secrets
2936
- services
30-
- endpoints
3137
- serviceaccounts
3238
verbs:
3339
- create
3440
- delete
3541
- get
3642
- list
3743
- patch
38-
- update
3944
- watch
45+
# RoleBindings bind the product ClusterRole to the per-cluster ServiceAccount.
46+
# Applied via SSA, tracked for orphan cleanup, and watched via .owns().
4047
- apiGroups:
4148
- rbac.authorization.k8s.io
4249
resources:
@@ -47,32 +54,23 @@ rules:
4754
- get
4855
- list
4956
- patch
50-
- update
5157
- watch
58+
# StatefulSets run the broker and (KRaft) controller role groups.
59+
# Applied via SSA, tracked for orphan cleanup, and watched via .owns().
5260
- apiGroups:
5361
- apps
5462
resources:
5563
- statefulsets
56-
verbs:
57-
- get
58-
- create
59-
- delete
60-
- list
61-
- patch
62-
- update
63-
- watch
64-
- apiGroups:
65-
- batch
66-
resources:
67-
- jobs
6864
verbs:
6965
- create
7066
- delete
7167
- get
7268
- list
7369
- patch
74-
- update
7570
- watch
71+
# PodDisruptionBudgets protect broker and controller role groups during voluntary disruptions.
72+
# Applied via SSA and tracked for orphan cleanup. PDBs are not watched by the controller
73+
# (no .owns() / .watches()), so watch is not needed.
7674
- apiGroups:
7775
- policy
7876
resources:
@@ -83,8 +81,6 @@ rules:
8381
- get
8482
- list
8583
- patch
86-
- update
87-
- watch
8884
- apiGroups:
8985
- apiextensions.k8s.io
9086
resources:
@@ -100,47 +96,55 @@ rules:
10096
- list
10197
- watch
10298
{{- end }}
99+
# Record Kubernetes events for reconciliation outcomes
103100
- apiGroups:
104101
- events.k8s.io
105102
resources:
106103
- events
107104
verbs:
108105
- create
109106
- patch
107+
# Watch and reconcile KafkaCluster resources (the primary resource for this controller)
110108
- apiGroups:
111109
- {{ include "operator.name" . }}.stackable.tech
112110
resources:
113111
- {{ include "operator.name" . }}clusters
114112
verbs:
115113
- get
116114
- list
117-
- patch
118115
- watch
116+
# Write status conditions back to the KafkaCluster object
119117
- apiGroups:
120118
- {{ include "operator.name" . }}.stackable.tech
121119
resources:
122120
- {{ include "operator.name" . }}clusters/status
123121
verbs:
124122
- patch
123+
# Read AuthenticationClasses to resolve TLS and Kerberos authentication configuration.
124+
# Only get is needed: the operator resolves classes via a direct client.get() call
125+
# during reconciliation; there is no controller watch on AuthenticationClass.
125126
- apiGroups:
126127
- authentication.stackable.tech
127128
resources:
128129
- authenticationclasses
129130
verbs:
130131
- get
131-
- list
132-
- watch
132+
# Manage Listener resources for broker bootstrap and per-rolegroup exposure.
133+
# Applied via SSA, tracked for orphan cleanup, and watched via .owns().
133134
- apiGroups:
134135
- listeners.stackable.tech
135136
resources:
136137
- listeners
137138
verbs:
139+
- create
140+
- delete
138141
- get
139142
- list
140-
- watch
141143
- patch
142-
- create
143-
- delete
144+
- watch
145+
# Bind the product ClusterRole to per-cluster ServiceAccounts (via RoleBindings above).
146+
# The operator creates RoleBindings that reference this ClusterRole, so it must have
147+
# permission to bind it.
144148
- apiGroups:
145149
- rbac.authorization.k8s.io
146150
resources:
@@ -157,6 +161,9 @@ metadata:
157161
labels:
158162
{{- include "operator.labels" . | nindent 4 }}
159163
rules:
164+
# The Kafka broker and KRaft controller pods need to read their own ConfigMaps,
165+
# Secrets, ServiceAccounts, and Services at runtime (e.g. via the Stackable secret
166+
# operator or init containers that inspect cluster configuration).
160167
- apiGroups:
161168
- ""
162169
resources:
@@ -166,6 +173,7 @@ rules:
166173
- services
167174
verbs:
168175
- get
176+
# Kafka pods may emit Kubernetes events (e.g. via the Stackable commons init container)
169177
- apiGroups:
170178
- events.k8s.io
171179
resources:
@@ -174,6 +182,7 @@ rules:
174182
- create
175183
- patch
176184
{{ if .Capabilities.APIVersions.Has "security.openshift.io/v1" }}
185+
# On OpenShift, the workload pods must be allowed to use the nonroot-v2 SCC
177186
- apiGroups:
178187
- security.openshift.io
179188
resources:

0 commit comments

Comments
 (0)