Skip to content

Commit afebb2b

Browse files
authored
chore: Describe RBAC rules, remove unnecessary rules (#129)
* chore: Describe RBAC rules, remove unnecessary rules * chore: Add missing comment on rule * chore: Remove the get for customresourcedefinitions for the operator clusterrole * chore: Remove the nodes list/watch rule for the operator clusterrole * chore: Remove the configmaps/secrets/serviceaccounts get rule for the product clusterrole * chore: Always allow customresourcedefinitions list/watch. Required for startup condition regardless of CRD maintenance * fix: Gate the openshift rules * chore: Simplify RBAC rule comments * chore: Remove the events.k8s.io rule from the product ClusterRole unless the products actually emit Kubernetes events * chore: Group rbac.authorization.k8s.io rules together * chore: Split the roles.yaml into separate files for clusterrole-operator.yaml and clusterrole-product.yaml * chore: Fix comment * chore: Update changelog
1 parent 9408ee7 commit afebb2b

3 files changed

Lines changed: 57 additions & 59 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 ([#129]).
10+
11+
[#129]: https://github.com/stackabletech/opensearch-operator/pull/129
12+
713
## [26.3.0] - 2026-03-16
814

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

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

Lines changed: 30 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1+
---
12
apiVersion: rbac.authorization.k8s.io/v1
23
kind: ClusterRole
34
metadata:
45
name: {{ include "operator.fullname" . }}-clusterrole
56
labels:
67
{{- include "operator.labels" . | nindent 4 }}
78
rules:
8-
- apiGroups:
9-
- ""
10-
resources:
11-
- nodes
12-
verbs:
13-
- list
14-
- watch
15-
# For automatic cluster domain detection
9+
# For automatic cluster domain detection.
1610
- apiGroups:
1711
- ""
1812
resources:
1913
- nodes/proxy
2014
verbs:
2115
- get
16+
# Manage core workload resources created per OpenSearchCluster.
17+
# Applied via SSA, tracked for orphan cleanup, and owned by the controller.
2218
- apiGroups:
2319
- ""
2420
resources:
2521
- configmaps
26-
- endpoints
27-
- pods
2822
- serviceaccounts
2923
- services
3024
verbs:
@@ -33,8 +27,9 @@ rules:
3327
- get
3428
- list
3529
- patch
36-
- update
3730
- watch
31+
# RoleBinding created per role group to bind the product ClusterRole to the workload
32+
# ServiceAccount. Applied via SSA, tracked for orphan cleanup, and owned by the controller.
3833
- apiGroups:
3934
- rbac.authorization.k8s.io
4035
resources:
@@ -45,8 +40,18 @@ rules:
4540
- get
4641
- list
4742
- patch
48-
- update
4943
- watch
44+
# Required to bind the product ClusterRole to the per-rolegroup ServiceAccount.
45+
- apiGroups:
46+
- rbac.authorization.k8s.io
47+
resources:
48+
- clusterroles
49+
verbs:
50+
- bind
51+
resourceNames:
52+
- {{ include "operator.name" . }}-clusterrole
53+
# StatefulSet created per role group. Applied via SSA, tracked for orphan cleanup, and
54+
# owned by the controller.
5055
- apiGroups:
5156
- apps
5257
resources:
@@ -57,8 +62,9 @@ rules:
5762
- get
5863
- list
5964
- patch
60-
- update
6165
- watch
66+
# PodDisruptionBudget created per role group. Applied via SSA, tracked for orphan cleanup,
67+
# and owned by the controller.
6268
- apiGroups:
6369
- policy
6470
resources:
@@ -69,92 +75,57 @@ rules:
6975
- get
7076
- list
7177
- patch
72-
- update
7378
- watch
79+
# Required for maintaining the CRDs within the operator (including the conversion webhook info).
80+
# Also for the startup condition check before the controller can run.
7481
- apiGroups:
7582
- apiextensions.k8s.io
7683
resources:
7784
- customresourcedefinitions
7885
verbs:
79-
- get
8086
# Required to maintain the CRD. The operator needs to do this, as it needs to enter e.g. it's
8187
# generated certificate in the conversion webhook.
8288
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
8389
- create
8490
- patch
91+
{{- end }}
8592
# Required for startup condition
8693
- list
8794
- watch
88-
{{- end }}
95+
# Listener created per role group for external access. Applied via SSA, tracked for orphan
96+
# cleanup, and owned by the controller.
8997
- apiGroups:
9098
- listeners.stackable.tech
9199
resources:
92100
- listeners
93101
verbs:
102+
- create
103+
- delete
94104
- get
95105
- list
96-
- watch
97106
- patch
98-
- create
99-
- delete
107+
- watch
108+
# Required to report reconciliation results and warnings back to the OpenSearchCluster object.
100109
- apiGroups:
101110
- events.k8s.io
102111
resources:
103112
- events
104113
verbs:
105114
- create
106115
- patch
116+
# Primary CRD: watched by the controller and read during reconciliation.
107117
- apiGroups:
108118
- {{ include "operator.name" . }}.stackable.tech
109119
resources:
110120
- {{ include "operator.name" . }}clusters
111121
verbs:
112122
- get
113123
- list
114-
- patch
115124
- watch
125+
# Status subresource: updated at the end of every reconciliation.
116126
- apiGroups:
117127
- {{ include "operator.name" . }}.stackable.tech
118128
resources:
119129
- {{ include "operator.name" . }}clusters/status
120130
verbs:
121131
- patch
122-
- apiGroups:
123-
- rbac.authorization.k8s.io
124-
resources:
125-
- clusterroles
126-
verbs:
127-
- bind
128-
resourceNames:
129-
- {{ include "operator.name" . }}-clusterrole
130-
---
131-
apiVersion: rbac.authorization.k8s.io/v1
132-
kind: ClusterRole
133-
metadata:
134-
name: {{ include "operator.name" . }}-clusterrole
135-
labels:
136-
{{- include "operator.labels" . | nindent 4 }}
137-
rules:
138-
- apiGroups:
139-
- ""
140-
resources:
141-
- configmaps
142-
- secrets
143-
- serviceaccounts
144-
verbs:
145-
- get
146-
- apiGroups:
147-
- events.k8s.io
148-
resources:
149-
- events
150-
verbs:
151-
- create
152-
- patch
153-
- apiGroups:
154-
- security.openshift.io
155-
resources:
156-
- securitycontextconstraints
157-
resourceNames:
158-
- nonroot-v2
159-
verbs:
160-
- use
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 OpenSearchCluster RoleBinding) to the ServiceAccount that
3+
# OpenSearch 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 the OpenSearch 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)