Skip to content

Commit 371dcc0

Browse files
committed
chore: Describe RBAC rules, remove unnecessary rules
1 parent 491b833 commit 371dcc0

1 file changed

Lines changed: 32 additions & 20 deletions

File tree

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

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ metadata:
66
labels:
77
{{- include "operator.labels" . | nindent 4 }}
88
rules:
9+
# For automatic cluster domain detection (list+watch required by the kube controller runtime)
910
- apiGroups:
1011
- ""
1112
resources:
@@ -20,95 +21,102 @@ rules:
2021
- nodes/proxy
2122
verbs:
2223
- get
24+
# Manage core workload resources created per OpaCluster.
25+
# All resources are applied via Server-Side Apply (create + patch) and tracked for
26+
# orphan cleanup (list + delete). The get verb is required by the ReconciliationPaused
27+
# strategy (which calls client.get() instead of apply_patch() when paused).
28+
# Resources watched by the controller also need watch.
29+
# - configmaps: role-group configs and discovery ConfigMaps; watched via .owns()
30+
# - services: role service, per-rolegroup headless and metrics services; watched via .owns()
31+
# - serviceaccounts: per-cluster ServiceAccount for the product workload pods
2332
- apiGroups:
2433
- ""
2534
resources:
26-
- pods
2735
- configmaps
28-
- secrets
2936
- services
30-
- endpoints
31-
- serviceaccounts
3237
verbs:
3338
- create
3439
- delete
3540
- get
3641
- list
3742
- patch
38-
- update
3943
- watch
4044
- apiGroups:
41-
- rbac.authorization.k8s.io
45+
- ""
4246
resources:
43-
- rolebindings
47+
- serviceaccounts
4448
verbs:
4549
- create
4650
- delete
4751
- get
4852
- list
4953
- patch
50-
- update
51-
- watch
54+
# Per-cluster RoleBinding binding the product ClusterRole to the workload ServiceAccount;
55+
# applied via SSA and tracked for orphan cleanup; not watched by the controller.
5256
- apiGroups:
53-
- apps
57+
- rbac.authorization.k8s.io
5458
resources:
55-
- daemonsets
59+
- rolebindings
5660
verbs:
57-
- get
5861
- create
5962
- delete
63+
- get
6064
- list
6165
- patch
62-
- update
63-
- watch
66+
# Per-rolegroup DaemonSet for OPA server pods; applied via SSA, tracked for orphan
67+
# cleanup, and watched via .owns().
6468
- apiGroups:
65-
- batch
69+
- apps
6670
resources:
67-
- jobs
71+
- daemonsets
6872
verbs:
6973
- create
74+
- delete
7075
- get
7176
- list
7277
- patch
73-
- update
7478
- watch
79+
# Read the CRD at startup to confirm it is established before starting the controller.
80+
# With maintenance enabled the operator also creates, patches, lists and watches CRDs
81+
# to maintain the CRD (e.g. entering generated certificates into the conversion webhook).
7582
- apiGroups:
7683
- apiextensions.k8s.io
7784
resources:
7885
- customresourcedefinitions
7986
verbs:
8087
- get
81-
# Required to maintain the CRD. The operator needs to do this, as it needs to enter e.g. it's
82-
# generated certificate in the conversion webhook.
8388
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
8489
- create
8590
- patch
8691
# Required for startup condition
8792
- list
8893
- watch
8994
{{- end }}
95+
# For publishing Kubernetes events from the controller reconciliation loop
9096
- apiGroups:
9197
- events.k8s.io
9298
resources:
9399
- events
94100
verbs:
95101
- create
96102
- patch
103+
# Watch and read OpaCluster resources to drive reconciliation
97104
- apiGroups:
98105
- {{ include "operator.name" . }}.stackable.tech
99106
resources:
100107
- {{ include "operator.name" . }}clusters
101108
verbs:
102109
- get
103110
- list
104-
- patch
105111
- watch
112+
# Patch OpaCluster status to report conditions back to the user
106113
- apiGroups:
107114
- {{ include "operator.name" . }}.stackable.tech
108115
resources:
109116
- {{ include "operator.name" . }}clusters/status
110117
verbs:
111118
- patch
119+
# Allow binding the product ClusterRole to per-cluster ServiceAccounts
112120
- apiGroups:
113121
- rbac.authorization.k8s.io
114122
resources:
@@ -126,6 +134,8 @@ metadata:
126134
labels:
127135
{{- include "operator.labels" . | nindent 4 }}
128136
rules:
137+
# OPA workload pods read ConfigMaps (bundle ConfigMaps, product config) and Secrets
138+
# (TLS credentials) and ServiceAccounts (for token projection) at runtime.
129139
- apiGroups:
130140
- ""
131141
resources:
@@ -136,6 +146,7 @@ rules:
136146
- get
137147
- list
138148
- watch
149+
# OPA workload pods publish Kubernetes events (e.g. from the user-info-fetcher sidecar)
139150
- apiGroups:
140151
- events.k8s.io
141152
resources:
@@ -144,6 +155,7 @@ rules:
144155
- create
145156
- patch
146157
{{ if .Capabilities.APIVersions.Has "security.openshift.io/v1" }}
158+
# Allow the workload pods to use the nonroot-v2 SCC on OpenShift
147159
- apiGroups:
148160
- security.openshift.io
149161
resources:

0 commit comments

Comments
 (0)