Skip to content

Commit 07a2706

Browse files
committed
chore: Simplify comments, group the rolebindings and clusterroles rules, and fix the crd management rule
1 parent 699e8ba commit 07a2706

1 file changed

Lines changed: 26 additions & 37 deletions

File tree

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

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ rules:
1414
- get
1515
# Manage core workload resources created per HbaseCluster.
1616
# All resources are applied via Server-Side Apply (create + patch) and tracked for
17-
# orphan cleanup (list + delete). get is needed when reconciliation is paused (the
18-
# operator reads current state instead of applying). Both resource types are watched
19-
# by the controller (.owns(Service), .watches(ConfigMap)) so they also need watch.
17+
# orphan cleanup (list + delete).
2018
# - configmaps: role group configuration and discovery configmap
2119
# - services: role group headless and metrics services
2220
- apiGroups:
@@ -31,10 +29,8 @@ rules:
3129
- list
3230
- patch
3331
- watch
34-
# Manage ServiceAccounts created per HbaseCluster for workload pods.
35-
# Applied via SSA (create + patch), tracked for orphan cleanup (list + delete).
36-
# get is needed when reconciliation is paused.
37-
# ServiceAccounts are not watched by the controller.
32+
# ServiceAccount created per HbaseCluster for workload pod identity.
33+
# Applied via SSA and tracked for orphan cleanup.
3834
- apiGroups:
3935
- ""
4036
resources:
@@ -45,10 +41,8 @@ rules:
4541
- get
4642
- list
4743
- patch
48-
# Manage RoleBindings that bind the product ClusterRole to per-cluster ServiceAccounts.
49-
# Applied via SSA (create + patch), tracked for orphan cleanup (list + delete).
50-
# get is needed when reconciliation is paused.
51-
# RoleBindings are not watched by the controller.
44+
# RoleBinding created per HbaseCluster to bind the product ClusterRole to the workload
45+
# ServiceAccount. Applied via SSA and tracked for orphan cleanup.
5246
- apiGroups:
5347
- rbac.authorization.k8s.io
5448
resources:
@@ -59,9 +53,16 @@ rules:
5953
- get
6054
- list
6155
- patch
62-
# Manage StatefulSets created per role group.
63-
# Applied via SSA (create + patch), tracked for orphan cleanup (list + delete),
64-
# watched by the controller via .owns(StatefulSet), and read on pause (get).
56+
# Required to bind the product ClusterRole to the per-cluster ServiceAccount.
57+
- apiGroups:
58+
- rbac.authorization.k8s.io
59+
resources:
60+
- clusterroles
61+
verbs:
62+
- bind
63+
resourceNames:
64+
- {{ include "operator.name" . }}-clusterrole
65+
# StatefulSet created per role group. Applied via SSA and tracked for orphan cleanup.
6566
- apiGroups:
6667
- apps
6768
resources:
@@ -73,10 +74,7 @@ rules:
7374
- list
7475
- patch
7576
- watch
76-
# Manage PodDisruptionBudgets created per role for availability guarantees.
77-
# Applied via SSA (create + patch), tracked for orphan cleanup (list + delete).
78-
# get is needed when reconciliation is paused.
79-
# PodDisruptionBudgets are not watched by the controller.
77+
# PodDisruptionBudget created per role. Applied via SSA and tracked for orphan cleanup.
8078
- apiGroups:
8179
- policy
8280
resources:
@@ -87,32 +85,31 @@ rules:
8785
- get
8886
- list
8987
- patch
88+
# Required for maintaining the CRDs within the operator (including the conversion webhook info).
89+
# Also for the startup condition check before the controller can run.
9090
- apiGroups:
9191
- apiextensions.k8s.io
9292
resources:
9393
- customresourcedefinitions
9494
verbs:
95-
- get
95+
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
9696
# Required to maintain the CRD. The operator needs to do this, as it needs to enter e.g. it's
9797
# generated certificate in the conversion webhook.
98-
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
9998
- create
10099
- patch
100+
{{- end }}
101101
# Required for startup condition
102102
- list
103103
- watch
104-
{{- end }}
105-
# For emitting Kubernetes events during reconciliation
104+
# Required to report reconciliation results and warnings back to the HbaseCluster object.
106105
- apiGroups:
107106
- events.k8s.io
108107
resources:
109108
- events
110109
verbs:
111110
- create
112111
- patch
113-
# The primary resource watched by the controller (Controller::new).
114-
# get + list + watch are required for the controller to observe HbaseClusters.
115-
# Status is updated via the separate /status subresource rule below.
112+
# Primary CRD: watched by Controller::new() and read during reconciliation.
116113
- apiGroups:
117114
- {{ include "operator.name" . }}.stackable.tech
118115
resources:
@@ -121,24 +118,16 @@ rules:
121118
- get
122119
- list
123120
- watch
124-
# For writing the HbaseCluster status subresource (apply_patch_status)
121+
# Status subresource: updated at the end of every reconciliation.
125122
- apiGroups:
126123
- {{ include "operator.name" . }}.stackable.tech
127124
resources:
128125
- {{ include "operator.name" . }}clusters/status
129126
verbs:
130127
- patch
131-
# For binding the product ClusterRole (hbase-clusterrole) to per-cluster ServiceAccounts
132-
# via namespaced RoleBindings created per HbaseCluster
133-
- apiGroups:
134-
- rbac.authorization.k8s.io
135-
resources:
136-
- clusterroles
137-
verbs:
138-
- bind
139-
resourceNames:
140-
- {{ include "operator.name" . }}-clusterrole
141128
---
129+
# Product ClusterRole: bound (via per HbaseCluster RoleBinding) to the ServiceAccount that HBase
130+
# workload pods (masters, regionServers, restServers) run as.
142131
apiVersion: rbac.authorization.k8s.io/v1
143132
kind: ClusterRole
144133
metadata:
@@ -155,7 +144,7 @@ rules:
155144
- create
156145
- patch
157146
{{ if .Capabilities.APIVersions.Has "security.openshift.io/v1" }}
158-
# Required on OpenShift to allow HBase pods to run as non-root
147+
# Required on OpenShift to allow the HBase pods to run as a non-root user.
159148
- apiGroups:
160149
- security.openshift.io
161150
resources:

0 commit comments

Comments
 (0)