Skip to content

Commit 9ca44ec

Browse files
committed
chore: Describe RBAC rules, remove unnecessary rules
1 parent 7952343 commit 9ca44ec

1 file changed

Lines changed: 41 additions & 11 deletions

File tree

  • deploy/helm/opensearch-operator/templates

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

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,34 @@ metadata:
55
labels:
66
{{- include "operator.labels" . | nindent 4 }}
77
rules:
8+
# For automatic cluster domain detection: nodes are listed/watched to find a node to
9+
# proxy through, and nodes/proxy is used to read kubelet info that contains the cluster domain.
810
- apiGroups:
911
- ""
1012
resources:
1113
- nodes
1214
verbs:
1315
- list
1416
- watch
15-
# For automatic cluster domain detection
1617
- apiGroups:
1718
- ""
1819
resources:
1920
- nodes/proxy
2021
verbs:
2122
- get
23+
# Manage core workload resources created per OpenSearchCluster.
24+
# All resources are applied via Server-Side Apply (create + patch) and tracked for
25+
# orphan cleanup (list + delete). The controller watches all of these via .owns() (watch).
26+
# get is required by the ReconciliationPaused strategy, which calls client.get() instead
27+
# of apply_patch() when reconciliation is paused.
28+
# update is NOT needed: SSA uses patch (HTTP PATCH), not update (HTTP PUT).
29+
# - configmaps: per-rolegroup configuration files mounted into pods
30+
# - serviceaccounts: per-rolegroup ServiceAccounts for workload pods
31+
# - services: per-rolegroup and discovery Services
2232
- apiGroups:
2333
- ""
2434
resources:
2535
- configmaps
26-
- endpoints
27-
- pods
2836
- serviceaccounts
2937
- services
3038
verbs:
@@ -33,8 +41,10 @@ rules:
3341
- get
3442
- list
3543
- patch
36-
- update
3744
- watch
45+
# RoleBindings bind the product ClusterRole to each per-rolegroup ServiceAccount so that
46+
# workload pods have the permissions they need at runtime.
47+
# Applied via SSA, tracked for orphan cleanup, and watched via .owns().
3848
- apiGroups:
3949
- rbac.authorization.k8s.io
4050
resources:
@@ -45,8 +55,9 @@ rules:
4555
- get
4656
- list
4757
- patch
48-
- update
4958
- watch
59+
# StatefulSets drive the OpenSearch node pods.
60+
# Applied via SSA, tracked for orphan cleanup, and watched via .owns().
5061
- apiGroups:
5162
- apps
5263
resources:
@@ -57,8 +68,9 @@ rules:
5768
- get
5869
- list
5970
- patch
60-
- update
6171
- watch
72+
# PodDisruptionBudgets limit voluntary disruptions during rolling upgrades and maintenance.
73+
# Applied via SSA, tracked for orphan cleanup, and watched via .owns().
6274
- apiGroups:
6375
- policy
6476
resources:
@@ -69,7 +81,6 @@ rules:
6981
- get
7082
- list
7183
- patch
72-
- update
7384
- watch
7485
- apiGroups:
7586
- apiextensions.k8s.io
@@ -86,39 +97,50 @@ rules:
8697
- list
8798
- watch
8899
{{- end }}
100+
# Listeners (stackable-listener-operator CRD) expose OpenSearch endpoints via a
101+
# cluster-level abstraction. Applied via SSA, tracked for orphan cleanup, watched via .owns().
102+
# get is also used directly in dereference.rs to fetch the discovery service Listener.
89103
- apiGroups:
90104
- listeners.stackable.tech
91105
resources:
92106
- listeners
93107
verbs:
108+
- create
109+
- delete
94110
- get
95111
- list
96-
- watch
97112
- patch
98-
- create
99-
- delete
113+
- watch
114+
# Events are emitted by the controller to report reconciliation results (e.g. errors,
115+
# status changes) visible via kubectl describe / kubectl get events.
100116
- apiGroups:
101117
- events.k8s.io
102118
resources:
103119
- events
104120
verbs:
105121
- create
106122
- patch
123+
# The primary CRD: the controller watches OpenSearchCluster objects to trigger reconciliation
124+
# and reads them during reconcile. patch is NOT needed here — the operator only writes
125+
# to the /status subresource (see rule below).
107126
- apiGroups:
108127
- {{ include "operator.name" . }}.stackable.tech
109128
resources:
110129
- {{ include "operator.name" . }}clusters
111130
verbs:
112131
- get
113132
- list
114-
- patch
115133
- watch
134+
# Status subresource: the controller calls apply_patch_status() after each reconcile to
135+
# update conditions (Available, Degraded, etc.) on the OpenSearchCluster object.
116136
- apiGroups:
117137
- {{ include "operator.name" . }}.stackable.tech
118138
resources:
119139
- {{ include "operator.name" . }}clusters/status
120140
verbs:
121141
- patch
142+
# The operator creates per-rolegroup RoleBindings that bind the product ClusterRole to
143+
# workload ServiceAccounts. bind permission on the product ClusterRole is required for that.
122144
- apiGroups:
123145
- rbac.authorization.k8s.io
124146
resources:
@@ -135,6 +157,10 @@ metadata:
135157
labels:
136158
{{- include "operator.labels" . | nindent 4 }}
137159
rules:
160+
# OpenSearch pods need read access to their own namespace resources at runtime:
161+
# - configmaps: read configuration (e.g. opensearch.yml, log4j2.properties)
162+
# - secrets: read TLS certificates and credentials mounted into the pod
163+
# - serviceaccounts: read own ServiceAccount metadata (e.g. for token projection)
138164
- apiGroups:
139165
- ""
140166
resources:
@@ -143,13 +169,17 @@ rules:
143169
- serviceaccounts
144170
verbs:
145171
- get
172+
# OpenSearch pods emit Kubernetes Events (e.g. via the Stackable logging framework).
146173
- apiGroups:
147174
- events.k8s.io
148175
resources:
149176
- events
150177
verbs:
151178
- create
152179
- patch
180+
# Required on OpenShift: allows OpenSearch pods to run with the nonroot-v2
181+
# SecurityContextConstraint, which permits running as a non-root UID without a specific
182+
# seccomp profile.
153183
- apiGroups:
154184
- security.openshift.io
155185
resources:

0 commit comments

Comments
 (0)