Skip to content

Commit 96f0806

Browse files
authored
feat(chart): bind default owner clusterroles in strict rbac mode (#2088)
* feat(chart): bind default owner clusterroles in strict rbac mode Signed-off-by: Hristo Hristov <me@hhristov.info> * feat(chart): make bindable clusterroles configurable via manager.rbac.bindableclusterroles Signed-off-by: Hristo Hristov <me@hhristov.info> --------- Signed-off-by: Hristo Hristov <me@hhristov.info>
1 parent 62d8d62 commit 96f0806

5 files changed

Lines changed: 44 additions & 3 deletions

File tree

charts/capsule/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,14 @@ The following Values have changed key or Value:
166166
| manager.options.userNames | list | `[]` | DEPRECATED: use users properties. Names of the users considered as Capsule users. |
167167
| manager.options.users | list | `[{"kind":"Group","name":"projectcapsule.dev"}]` | Define entities which are considered part of the Capsule construct. Users not mentioned here will be ignored by Capsule |
168168
| manager.options.workers | int | `1` | Workers (MaxConcurrentReconciles) is the maximum number of concurrent Reconciles which can be run (ALPHA). |
169+
| manager.rbac.bindableClusterRoles | list | `["admin"]` | ClusterRoles the Capsule controller is allowed to bind (verb `bind`) when strict RBAC is enabled, in addition to the roles Capsule manages (manager.options.rbac provisioner, deleter, administrationClusterRoles and promotionClusterRoles), which are always bindable. Add any custom tenant-owner ClusterRoles here. |
169170
| manager.rbac.clusterRole.extraResources | list | `[]` | Extra cluster-scoped RBAC PolicyRules to add to a ClusterRole created by this chart and bound to the Capsule ServiceAccount. |
170171
| manager.rbac.create | bool | `true` | Specifies whether RBAC resources should be created. |
171172
| manager.rbac.existingClusterRoles | list | `[]` | Specifies further cluster roles to be added to the Capsule manager service account. |
172173
| manager.rbac.existingRoles | list | `[]` | Specifies further cluster roles to be added to the Capsule manager service account. |
173174
| manager.rbac.minimal | bool | `false` | DEPRECATED: use strict instead. Former name of the strict option; takes effect when either flag is true. |
174175
| manager.rbac.role.extraResources | list | `[]` | Extra namespaced RBAC PolicyRules to add to a Role created by this chart and bound to the Capsule ServiceAccount. |
175-
| manager.rbac.strict | bool | `false` | Strongly restrict the RBAC assigned to Capsule Controller. When set to true you must aggregate further permissions by yourself. |
176+
| manager.rbac.strict | bool | `false` | Strongly restrict the RBAC assigned to Capsule Controller. The default owner ClusterRoles (admin, provisioner and deleter) can be bound to tenant owners out of the box; add custom owner ClusterRoles via bindableClusterRoles. Permissions beyond binding (e.g. TenantResource replication) must be aggregated by yourself via ClusterRoles labeled projectcapsule.dev/aggregate-to-controller: "true". |
176177
| manager.readinessProbe | object | `{"httpGet":{"path":"/readyz","port":10080}}` | Configure the readiness probe using Deployment probe spec |
177178
| manager.resources | object | `{}` | Set the resource requests/limits for the Capsule manager container |
178179
| manager.securityContext | object | `{}` | Set the securityContext for the Capsule container |
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fullnameOverride: capsule
2+
manager:
3+
rbac:
4+
create: true
5+
strict: true
6+
bindableClusterRoles:
7+
- admin
8+
- edit

charts/capsule/templates/rbac.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ rules:
273273
- "get"
274274
- "list"
275275
- "watch"
276+
- "create"
276277
- "patch"
277278
- "update"
278279
- "delete"
@@ -433,6 +434,15 @@ rules:
433434
- update
434435
- patch
435436
- delete
437+
{{- $bindable := concat $.Values.manager.rbac.bindableClusterRoles (list $.Values.manager.options.rbac.provisioner $.Values.manager.options.rbac.deleter) $.Values.manager.options.rbac.administrationClusterRoles $.Values.manager.options.rbac.promotionClusterRoles | uniq | sortAlpha }}
438+
- apiGroups: ["rbac.authorization.k8s.io"]
439+
resources: ["clusterroles"]
440+
resourceNames:
441+
{{- range $bindable }}
442+
- {{ . | quote }}
443+
{{- end }}
444+
verbs:
445+
- bind
436446
- apiGroups: ["rbac.authorization.k8s.io"]
437447
resources: ["clusterrolebindings"]
438448
verbs:
@@ -462,6 +472,9 @@ rules:
462472
- apiGroups: [""]
463473
resources: ["secrets"]
464474
verbs: ["get", "list", "watch", "create", "update", "patch"]
475+
- apiGroups: [""]
476+
resources: ["events"]
477+
verbs: ["create", "patch"]
465478
---
466479
kind: RoleBinding
467480
apiVersion: rbac.authorization.k8s.io/v1

charts/capsule/values.schema.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,13 @@
672672
"rbac": {
673673
"type": "object",
674674
"properties": {
675+
"bindableClusterRoles": {
676+
"description": "ClusterRoles the Capsule controller is allowed to bind (verb `bind`) when strict RBAC is enabled, in addition to the roles Capsule manages (manager.options.rbac provisioner, deleter, administrationClusterRoles and promotionClusterRoles), which are always bindable. Add any custom tenant-owner ClusterRoles here.",
677+
"type": "array",
678+
"items": {
679+
"type": "string"
680+
}
681+
},
675682
"clusterRole": {
676683
"type": "object",
677684
"properties": {
@@ -707,7 +714,7 @@
707714
}
708715
},
709716
"strict": {
710-
"description": "Strongly restrict the RBAC assigned to Capsule Controller. When set to true you must aggregate further permissions by yourself.",
717+
"description": "Strongly restrict the RBAC assigned to Capsule Controller. The default owner ClusterRoles (admin, provisioner and deleter) can be bound to tenant owners out of the box; add custom owner ClusterRoles via bindableClusterRoles. Permissions beyond binding (e.g. TenantResource replication) must be aggregated by yourself via ClusterRoles labeled projectcapsule.dev/aggregate-to-controller: \"true\".",
711718
"type": "boolean"
712719
}
713720
}

charts/capsule/values.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,25 @@ manager:
153153
create: true
154154

155155
# -- Strongly restrict the RBAC assigned to Capsule Controller.
156-
# When set to true you must aggregate further permissions by yourself.
156+
# The default owner ClusterRoles (admin, provisioner and deleter) can be bound
157+
# to tenant owners out of the box; add custom owner ClusterRoles via
158+
# bindableClusterRoles. Permissions beyond binding (e.g. TenantResource
159+
# replication) must be aggregated by yourself via ClusterRoles labeled
160+
# projectcapsule.dev/aggregate-to-controller: "true".
157161
strict: false
158162

159163
# -- DEPRECATED: use strict instead.
160164
# Former name of the strict option; takes effect when either flag is true.
161165
minimal: false
162166

167+
# -- ClusterRoles the Capsule controller is allowed to bind (verb `bind`) when
168+
# strict RBAC is enabled, in addition to the roles Capsule manages
169+
# (manager.options.rbac provisioner, deleter, administrationClusterRoles and
170+
# promotionClusterRoles), which are always bindable. Add any custom
171+
# tenant-owner ClusterRoles here.
172+
bindableClusterRoles:
173+
- admin
174+
163175
# -- Specifies further cluster roles to be added to the Capsule manager service account.
164176
existingClusterRoles: []
165177
# - cluster-admin

0 commit comments

Comments
 (0)