Skip to content

Commit 5e65f59

Browse files
NickLarsenNZrazvan
andauthored
chore: Describe RBAC rules, remove unnecessary rules (#869)
* 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 descriptions * chore: Remove the get for customresourcedefinitions for the operator clusterrole Not needed for CRD maintenance * chore: Remove the configmaps/secrets/serviceaccounts get rule for the product clusterrole Product pods will have necessary secrets/configmaps mounted and not directly talk to Kubernetes * chore: Always allow list/watch for customresourcedefinitions Required for startup condition * chore: Simplify the rule descriptions * chore: Remove the events.k8s.io rule from the product ClusterRole The operator takes care of events * chore: Keep the rbac.authorization.k8s.io rules within a ClusterRole close to each other * chore: Split the roles.yaml into separate files for clusterrole-operator.yaml and clusterrole-product.yaml * chore: Restore secrets/delete permission Now needed since #876 Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com> --------- Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>
1 parent 5511a98 commit 5e65f59

3 files changed

Lines changed: 71 additions & 82 deletions

File tree

CHANGELOG.md

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

77
### Changed
88

9+
- Document Helm deployed RBAC permissions and remove unnecessary permissions ([#869]).
910
- Bump stackable-operator to 0.109.0 ([#877]).
1011
- Warn when an unsupported OIDC client authentication method is configured ([#877]).
1112

@@ -16,6 +17,7 @@ All notable changes to this project will be documented in this file.
1617
could cause Trino Pods to have different shared secrets, causing workers failing to join the coordinator.
1718
This fix places the secrets in mutable Kubernetes Secrets going forward and migrates existing immutable Secrets to mutable by re-creating them ([#876]).
1819

20+
[#869]: https://github.com/stackabletech/trino-operator/pull/869
1921
[#876]: https://github.com/stackabletech/trino-operator/pull/876
2022
[#877]: https://github.com/stackabletech/trino-operator/pull/877
2123

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

Lines changed: 48 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,54 @@ metadata:
66
labels:
77
{{- include "operator.labels" . | nindent 4 }}
88
rules:
9-
# For OPA dependents. Note that OPA it's self is listed here because it's own resource name
10-
# doesn't follow the *clusters convention
9+
# For automatic cluster domain detection
1110
- apiGroups:
12-
- opa.stackable.tech
11+
- ""
1312
resources:
14-
- regorules
13+
- nodes/proxy
1514
verbs:
16-
- create
1715
- get
18-
- list
19-
- watch
20-
- patch
16+
# Manage core workload resources created per TrinoCluster.
17+
# All resources are applied via Server-Side Apply (create + patch) and tracked for
18+
# orphan cleanup (list + delete).
2119
- apiGroups:
2220
- ""
2321
resources:
24-
- nodes
22+
- configmaps
23+
- services
2524
verbs:
25+
- create
26+
- delete
27+
- get
2628
- list
29+
- patch
2730
- watch
28-
# For automatic cluster domain detection
31+
# ServiceAccount created per TrinoCluster for workload pod identity.
32+
# Applied via SSA and tracked for orphan cleanup.
2933
- apiGroups:
3034
- ""
3135
resources:
32-
- nodes/proxy
36+
- serviceaccounts
3337
verbs:
38+
- create
39+
- delete
3440
- get
41+
- list
42+
- patch
43+
# Shared internal authentication secrets (communication key and spooling secret).
44+
# Delete is needed to migrate immutable secrets to mutable ones.
45+
# Orphan cleanup not needed (instead, Kubernetes GC via owner reference).
3546
- apiGroups:
3647
- ""
3748
resources:
38-
- pods
39-
- configmaps
4049
- secrets
41-
- services
42-
- endpoints
43-
- serviceaccounts
4450
verbs:
4551
- create
4652
- delete
4753
- get
48-
- list
4954
- patch
50-
- update
51-
- watch
55+
# RoleBinding created per TrinoCluster to bind the product ClusterRole to the workload
56+
# ServiceAccount. Applied via SSA and tracked for orphan cleanup.
5257
- apiGroups:
5358
- rbac.authorization.k8s.io
5459
resources:
@@ -59,32 +64,29 @@ rules:
5964
- get
6065
- list
6166
- patch
62-
- update
63-
- watch
67+
# Required to bind the product ClusterRole to the per-cluster ServiceAccount.
6468
- apiGroups:
65-
- apps
69+
- rbac.authorization.k8s.io
6670
resources:
67-
- statefulsets
71+
- clusterroles
6872
verbs:
69-
- get
70-
- create
71-
- delete
72-
- list
73-
- patch
74-
- update
75-
- watch
73+
- bind
74+
resourceNames:
75+
- {{ include "operator.name" . }}-clusterrole
76+
# StatefulSet created per role group. Applied via SSA, tracked for orphan cleanup, and
77+
# owned by the controller.
7678
- apiGroups:
77-
- batch
79+
- apps
7880
resources:
79-
- jobs
81+
- statefulsets
8082
verbs:
8183
- create
8284
- delete
8385
- get
8486
- list
8587
- patch
86-
- update
8788
- watch
89+
# PodDisruptionBudget created per role. Applied via SSA and tracked for orphan cleanup.
8890
- apiGroups:
8991
- policy
9092
resources:
@@ -95,56 +97,59 @@ rules:
9597
- get
9698
- list
9799
- patch
98-
- update
99-
- watch
100+
# Required for maintaining the CRDs within the operator (including the conversion webhook info).
101+
# Also for the startup condition check before the controller can run.
100102
- apiGroups:
101103
- apiextensions.k8s.io
102104
resources:
103105
- customresourcedefinitions
104106
verbs:
105-
- get
106107
# Required to maintain the CRD. The operator needs to do this, as it needs to enter e.g. it's
107108
# generated certificate in the conversion webhook.
108109
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
109110
- create
110111
- patch
112+
{{- end }}
111113
# Required for startup condition
112114
- list
113115
- watch
114-
{{- end }}
116+
# Listener created per role group for external access. Applied via SSA and tracked for orphan
117+
# cleanup.
115118
- apiGroups:
116119
- listeners.stackable.tech
117120
resources:
118121
- listeners
119122
verbs:
123+
- create
124+
- delete
120125
- get
121126
- list
122-
- watch
123127
- patch
124-
- create
125-
- delete
128+
# Required to report reconciliation results and warnings back to the TrinoCluster object.
126129
- apiGroups:
127130
- events.k8s.io
128131
resources:
129132
- events
130133
verbs:
131134
- create
132135
- patch
136+
# Primary CRD: watched by the controller and read during reconciliation.
133137
- apiGroups:
134138
- {{ include "operator.name" . }}.stackable.tech
135139
resources:
136140
- {{ include "operator.name" . }}clusters
137141
verbs:
138142
- get
139143
- list
140-
- patch
141144
- watch
145+
# Status subresource: updated at the end of every reconciliation.
142146
- apiGroups:
143147
- {{ include "operator.name" . }}.stackable.tech
144148
resources:
145149
- {{ include "operator.name" . }}clusters/status
146150
verbs:
147151
- patch
152+
# Read S3 connection configuration referenced in catalog definitions.
148153
- apiGroups:
149154
- s3.stackable.tech
150155
resources:
@@ -153,6 +158,7 @@ rules:
153158
- get
154159
- list
155160
- watch
161+
# Read TrinoCatalog resources referenced in the TrinoCluster spec.
156162
- apiGroups:
157163
- trino.stackable.tech
158164
resources:
@@ -161,6 +167,7 @@ rules:
161167
- get
162168
- list
163169
- watch
170+
# Read authentication class configuration referenced in the TrinoCluster spec.
164171
- apiGroups:
165172
- authentication.stackable.tech
166173
resources:
@@ -169,44 +176,3 @@ rules:
169176
- get
170177
- list
171178
- watch
172-
- apiGroups:
173-
- rbac.authorization.k8s.io
174-
resources:
175-
- clusterroles
176-
verbs:
177-
- bind
178-
resourceNames:
179-
- {{ include "operator.name" . }}-clusterrole
180-
---
181-
apiVersion: rbac.authorization.k8s.io/v1
182-
kind: ClusterRole
183-
metadata:
184-
name: {{ include "operator.name" . }}-clusterrole
185-
labels:
186-
{{- include "operator.labels" . | nindent 4 }}
187-
rules:
188-
- apiGroups:
189-
- ""
190-
resources:
191-
- configmaps
192-
- secrets
193-
- serviceaccounts
194-
verbs:
195-
- get
196-
- apiGroups:
197-
- events.k8s.io
198-
resources:
199-
- events
200-
verbs:
201-
- create
202-
- patch
203-
{{ if .Capabilities.APIVersions.Has "security.openshift.io/v1" }}
204-
- apiGroups:
205-
- security.openshift.io
206-
resources:
207-
- securitycontextconstraints
208-
resourceNames:
209-
- nonroot-v2
210-
verbs:
211-
- use
212-
{{ end }}
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 TrinoCluster RoleBinding) to the ServiceAccount that Trino
3+
# workload pods (coordinators, workers) 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 Trino 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)