Skip to content

Commit 2e274b3

Browse files
committed
ceph: Use aggregated ClusterRoles
The ClusterRoles in the manifests (and helm chart) for the ceph provider have been updated to use [aggregated ClusterRoles][1]. All ClusterRoles have been split into 2 ClusterRoles. An aggregated ClusterRole without any rules, named the same, but with an aggregationRule that matches labels in the format 'rbac.ceph.rook.io/aggregate-to-<ClusterRole name>: "true"'. A second ClusterRole which contains the existing rules named '<ClusterRole name>-rules', with label 'rbac.ceph.rook.io/aggregate-to-<ClusterRole name>: "true"'. These two ClusterRoles give the same behaviour as the previous ClusterRole. Additional rules to a ClusterRole can now be provided by creating a new ClusterRole with the correct label. This should help make updates simpler. Fixes rook#2634. [1]: https://kubernetes.io/docs/reference/access-authn-authz/rbac/#aggregated-clusterroles Signed-off-by: Kaushal M <[email protected]>
1 parent 33c8269 commit 2e274b3

File tree

9 files changed

+322
-0
lines changed

9 files changed

+322
-0
lines changed

cluster/charts/rook-ceph/templates/clusterrole.yaml

+83
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ metadata:
77
labels:
88
operator: rook
99
storage-backend: ceph
10+
aggregationRule:
11+
clusterRoleSelectors:
12+
- matchLabels:
13+
rbac.rook.ceph.io/aggregate-to-rook-ceph-cluster-mgmt: "true"
14+
rules: []
15+
---
16+
apiVersion: rbac.authorization.k8s.io/v1beta1
17+
kind: ClusterRole
18+
metadata:
19+
name: rook-ceph-cluster-mgmt-rules
20+
labels:
21+
operator: rook
22+
storage-backend: ceph
23+
rbac.rook.ceph.io/aggregate-to-rook-ceph-cluster-mgmt: "true"
1024
rules:
1125
- apiGroups:
1226
- ""
@@ -46,6 +60,20 @@ metadata:
4660
labels:
4761
operator: rook
4862
storage-backend: ceph
63+
aggregationRule:
64+
clusterRoleSelectors:
65+
- matchLabels:
66+
rbac.ceph.rook.io/aggregate-to-rook-ceph-global: "true"
67+
rules: []
68+
---
69+
apiVersion: rbac.authorization.k8s.io/v1beta1
70+
kind: ClusterRole
71+
metadata:
72+
name: rook-ceph-global-rules
73+
labels:
74+
operator: rook
75+
storage-backend: ceph
76+
rbac.ceph.rook.io/aggregate-to-rook-ceph-global: "true"
4977
rules:
5078
- apiGroups:
5179
- ""
@@ -115,6 +143,20 @@ metadata:
115143
labels:
116144
operator: rook
117145
storage-backend: ceph
146+
aggregationRule:
147+
clusterRoleSelectors:
148+
- matchLabels:
149+
rbac.ceph.rook.io/aggregate-to-rook-ceph-mgr-cluster: "true"
150+
rules: []
151+
---
152+
kind: ClusterRole
153+
apiVersion: rbac.authorization.k8s.io/v1beta1
154+
metadata:
155+
name: rook-ceph-mgr-cluster-rules
156+
labels:
157+
operator: rook
158+
storage-backend: ceph
159+
rbac.ceph.rook.io/aggregate-to-rook-ceph-mgr-cluster: "true"
118160
rules:
119161
- apiGroups:
120162
- ""
@@ -132,6 +174,18 @@ kind: ClusterRole
132174
apiVersion: rbac.authorization.k8s.io/v1beta1
133175
metadata:
134176
name: rook-ceph-mgr-system
177+
aggregationRule:
178+
clusterRoleSelectors:
179+
- matchLabels:
180+
rbac.ceph.rook.io/aggregate-to-rook-ceph-mgr-system: "true"
181+
rules: []
182+
---
183+
kind: ClusterRole
184+
apiVersion: rbac.authorization.k8s.io/v1beta1
185+
metadata:
186+
name: rook-ceph-mgr-system-rules
187+
labels:
188+
rbac.ceph.rook.io/aggregate-to-rook-ceph-mgr-system: "true"
135189
rules:
136190
- apiGroups:
137191
- ""
@@ -150,6 +204,20 @@ metadata:
150204
labels:
151205
operator: rook
152206
storage-backend: ceph
207+
aggregationRule:
208+
clusterRoleSelectors:
209+
- matchLabels:
210+
rbac.ceph.rook.io/aggregate-to-rook-ceph-agent-mount: "true"
211+
rules: []
212+
---
213+
apiVersion: rbac.authorization.k8s.io/v1beta1
214+
kind: ClusterRole
215+
metadata:
216+
name: rook-ceph-agent-mount-rules
217+
labels:
218+
operator: rook
219+
storage-backend: ceph
220+
rbac.ceph.rook.io/aggregate-to-rook-ceph-agent-mount: "true"
153221
rules:
154222
- apiGroups:
155223
- ""
@@ -168,6 +236,21 @@ metadata:
168236
operator: rook
169237
storage-backend: ceph
170238
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
239+
aggregationRule:
240+
clusterRoleSelectors:
241+
- matchLabels:
242+
rbac.ceph.rook.io/aggregate-to-rook-ceph-system-psp-user: "true"
243+
rules: []
244+
---
245+
apiVersion: rbac.authorization.k8s.io/v1beta1
246+
kind: ClusterRole
247+
metadata:
248+
name: rook-ceph-system-psp-user-rules
249+
labels:
250+
operator: rook
251+
storage-backend: ceph
252+
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
253+
rbac.ceph.rook.io/aggregate-to-rook-ceph-system-psp-user: "true"
171254
rules:
172255
- apiGroups:
173256
- apps

cluster/examples/kubernetes/ceph/common.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,20 @@ metadata:
206206
labels:
207207
operator: rook
208208
storage-backend: ceph
209+
aggregationRule:
210+
clusterRoleSelectors:
211+
- matchLabels:
212+
rbac.ceph.rook.io/aggregate-to-rook-ceph-cluster-mgmt: "true"
213+
rules: []
214+
---
215+
apiVersion: rbac.authorization.k8s.io/v1beta1
216+
kind: ClusterRole
217+
metadata:
218+
name: rook-ceph-cluster-mgmt-rules
219+
labels:
220+
operator: rook
221+
storage-backend: ceph
222+
rbac.ceph.rook.io/aggregate-to-rook-ceph-cluster-mgmt: "true"
209223
rules:
210224
- apiGroups:
211225
- ""
@@ -282,6 +296,20 @@ metadata:
282296
labels:
283297
operator: rook
284298
storage-backend: ceph
299+
aggregationRule:
300+
clusterRoleSelectors:
301+
- matchLabels:
302+
rbac.ceph.rook.io/aggregate-to-rook-ceph-global: "true"
303+
rules: []
304+
---
305+
apiVersion: rbac.authorization.k8s.io/v1beta1
306+
kind: ClusterRole
307+
metadata:
308+
name: rook-ceph-global-rules
309+
labels:
310+
operator: rook
311+
storage-backend: ceph
312+
rbac.ceph.rook.io/aggregate-to-rook-ceph-global: "true"
285313
rules:
286314
- apiGroups:
287315
- ""
@@ -351,6 +379,20 @@ metadata:
351379
labels:
352380
operator: rook
353381
storage-backend: ceph
382+
aggregationRule:
383+
clusterRoleSelectors:
384+
- matchLabels:
385+
rbac.ceph.rook.io/aggregate-to-rook-ceph-mgr-cluster: "true"
386+
rules: []
387+
---
388+
kind: ClusterRole
389+
apiVersion: rbac.authorization.k8s.io/v1beta1
390+
metadata:
391+
name: rook-ceph-mgr-cluster-rules
392+
labels:
393+
operator: rook
394+
storage-backend: ceph
395+
rbac.ceph.rook.io/aggregate-to-rook-ceph-mgr-cluster: "true"
354396
rules:
355397
- apiGroups:
356398
- ""
@@ -444,6 +486,19 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
444486
metadata:
445487
name: rook-ceph-mgr-system
446488
namespace: rook-ceph
489+
aggregationRule:
490+
clusterRoleSelectors:
491+
- matchLabels:
492+
rbac.ceph.rook.io/aggregate-to-rook-ceph-mgr-system: "true"
493+
rules: []
494+
---
495+
kind: ClusterRole
496+
apiVersion: rbac.authorization.k8s.io/v1beta1
497+
metadata:
498+
name: rook-ceph-mgr-system-rules
499+
namespace: rook-ceph
500+
labels:
501+
rbac.ceph.rook.io/aggregate-to-rook-ceph-mgr-system: "true"
447502
rules:
448503
- apiGroups:
449504
- ""

cluster/examples/kubernetes/ceph/csi/rbac/cephfs/csi-nodeplugin-rbac.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ kind: ClusterRole
88
apiVersion: rbac.authorization.k8s.io/v1
99
metadata:
1010
name: cephfs-csi-nodeplugin
11+
aggregationRule:
12+
clusterRoleSelectors:
13+
- matchLabels:
14+
rbac.ceph.rook.io/aggregate-to-cephfs-csi-nodeplugin: "true"
15+
rules: []
16+
---
17+
kind: ClusterRole
18+
apiVersion: rbac.authorization.k8s.io/v1
19+
metadata:
20+
name: cephfs-csi-nodeplugin-rules
21+
labels:
22+
rbac.ceph.rook.io/aggregate-to-cephfs-csi-nodeplugin: "true"
1123
rules:
1224
- apiGroups: [""]
1325
resources: ["nodes"]

cluster/examples/kubernetes/ceph/csi/rbac/cephfs/csi-provisioner-rbac.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ kind: ClusterRole
88
apiVersion: rbac.authorization.k8s.io/v1
99
metadata:
1010
name: cephfs-external-provisioner-runner
11+
aggregationRule:
12+
clusterRoleSelectors:
13+
- matchLabels:
14+
rbac.ceph.rook.io/aggregate-to-cephfs-external-provisioner-runner: "true"
15+
rules: []
16+
---
17+
kind: ClusterRole
18+
apiVersion: rbac.authorization.k8s.io/v1
19+
metadata:
20+
name: cephfs-external-provisioner-runner-rules
21+
labels:
22+
rbac.ceph.rook.io/aggregate-to-cephfs-external-provisioner-runner: "true"
1123
rules:
1224
- apiGroups: [""]
1325
resources: ["secrets"]

cluster/examples/kubernetes/ceph/csi/rbac/rbd/csi-nodeplugin-rbac.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ kind: ClusterRole
99
apiVersion: rbac.authorization.k8s.io/v1
1010
metadata:
1111
name: rbd-csi-nodeplugin
12+
aggregationRule:
13+
clusterRoleSelectors:
14+
- matchLabels:
15+
rbac.ceph.rook.io/aggregate-to-rbd-csi-nodeplugin: "true"
16+
rules: []
17+
---
18+
kind: ClusterRole
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
metadata:
21+
name: rbd-csi-nodeplugin-rules
22+
labels:
23+
rbac.ceph.rook.io/aggregate-to-rbd-csi-nodeplugin: "true"
1224
rules:
1325
- apiGroups: [""]
1426
resources: ["nodes"]

cluster/examples/kubernetes/ceph/csi/rbac/rbd/csi-provisioner-rbac.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ kind: ClusterRole
99
apiVersion: rbac.authorization.k8s.io/v1
1010
metadata:
1111
name: rbd-external-provisioner-runner
12+
aggregationRule:
13+
clusterRoleSelectors:
14+
- matchLabels:
15+
rbac.ceph.rook.io/aggregate-to-rbd-external-provisioner-runner: "true"
16+
rules: []
17+
---
18+
kind: ClusterRole
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
metadata:
21+
name: rbd-external-provisioner-runner-rules
22+
labels:
23+
rbac.ceph.rook.io/aggregate-to-rbd-external-provisioner-runner: "true"
1224
rules:
1325
- apiGroups: [""]
1426
resources: ["secrets"]

cluster/examples/kubernetes/ceph/monitoring/prometheus.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ kind: ClusterRole
99
metadata:
1010
name: prometheus
1111
namespace: rook-ceph
12+
aggregationRule:
13+
clusterRoleSelectors:
14+
- matchLabels:
15+
rbac.ceph.rook.io/aggregate-to-prometheus: "true"
16+
rules: []
17+
---
18+
apiVersion: rbac.authorization.k8s.io/v1beta1
19+
kind: ClusterRole
20+
metadata:
21+
name: prometheus-rules
22+
namespace: rook-ceph
23+
labels:
24+
rbac.ceph.rook.io/aggregate-to-prometheus: "true"
1225
rules:
1326
- apiGroups: [""]
1427
resources:

tests/framework/installer/ceph_installer.go

+8
Original file line numberDiff line numberDiff line change
@@ -407,20 +407,28 @@ func (h *CephInstaller) UninstallRookFromMultipleNS(systemNamespace string, name
407407
h.k8shelper.Clientset.RbacV1beta1().ClusterRoleBindings().Delete("rook-ceph-mgr-cluster", nil)
408408
h.k8shelper.Clientset.CoreV1().ServiceAccounts(systemNamespace).Delete("rook-ceph-system", nil)
409409
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rook-ceph-cluster-mgmt", nil)
410+
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rook-ceph-cluster-mgmt-rules", nil)
410411
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rook-ceph-mgr-cluster", nil)
412+
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rook-ceph-mgr-cluster-rules", nil)
411413
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rook-ceph-mgr-system", nil)
414+
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rook-ceph-mgr-system-rules", nil)
412415
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rook-ceph-global", nil)
416+
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rook-ceph-global-rules", nil)
413417
h.k8shelper.Clientset.RbacV1beta1().Roles(systemNamespace).Delete("rook-ceph-system", nil)
414418

415419
h.k8shelper.Clientset.RbacV1beta1().ClusterRoleBindings().Delete("rbd-csi-nodeplugin", nil)
416420
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rbd-csi-nodeplugin", nil)
421+
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rbd-csi-nodeplugin-rules", nil)
417422
h.k8shelper.Clientset.RbacV1beta1().ClusterRoleBindings().Delete("rbd-csi-provisioner-role", nil)
418423
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rbd-external-provisioner-runner", nil)
424+
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("rbd-external-provisioner-runner-rules", nil)
419425

420426
h.k8shelper.Clientset.RbacV1beta1().ClusterRoleBindings().Delete("cephfs-csi-nodeplugin", nil)
421427
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("cephfs-csi-nodeplugin", nil)
428+
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("cephfs-csi-nodeplugin-rules", nil)
422429
h.k8shelper.Clientset.RbacV1beta1().ClusterRoleBindings().Delete("cephfs-csi-provisioner-role", nil)
423430
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("cephfs-external-provisioner-runner", nil)
431+
h.k8shelper.Clientset.RbacV1beta1().ClusterRoles().Delete("cephfs-external-provisioner-runner-rules", nil)
424432

425433
h.k8shelper.Clientset.CoreV1().ConfigMaps(systemNamespace).Delete("csi-rbd-config", nil)
426434
h.k8shelper.Clientset.CoreV1().ConfigMaps(systemNamespace).Delete("csi-cephfs-config", nil)

0 commit comments

Comments
 (0)