Skip to content

Commit e71f06f

Browse files
committed
feat(chart): allow specificing additional controller rbac
Signed-off-by: Oliver Baehler <oliver@sudo-i.net>
1 parent 2001feb commit e71f06f

5 files changed

Lines changed: 107 additions & 2 deletions

File tree

charts/capsule/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ The following Values have changed key or Value:
143143
| manager.options.userNames | list | `[]` | DEPRECATED: use users properties. Names of the users considered as Capsule users. |
144144
| 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 |
145145
| manager.options.workers | int | `1` | Workers (MaxConcurrentReconciles) is the maximum number of concurrent Reconciles which can be run (ALPHA). |
146+
| manager.rbac.clusterRole.extraResources | list | `[]` | |
146147
| manager.rbac.create | bool | `true` | Specifies whether RBAC resources should be created. |
147148
| manager.rbac.existingClusterRoles | list | `[]` | Specifies further cluster roles to be added to the Capsule manager service account. |
148149
| manager.rbac.existingRoles | list | `[]` | Specifies further cluster roles to be added to the Capsule manager service account. |
150+
| manager.rbac.role.extraResources | list | `[]` | |
149151
| manager.rbac.strict | bool | `false` | Strongly restrict the RBAC assigned to Capsule Controller. When set to true you must aggregate further permissions by yourself. |
150152
| manager.readinessProbe | object | `{"httpGet":{"path":"/readyz","port":10080}}` | Configure the readiness probe using Deployment probe spec |
151153
| manager.resources | object | `{}` | Set the resource requests/limits for the Capsule manager container |

charts/capsule/ci/test-values.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ manager:
77
options:
88
capsuleUserGroups: ["custom-group-1", "custom-group-2"]
99
userNames: ["custom-user-1", "custom-user-2"]
10-
1110
rbac:
1211
create: true
1312
existingClusterRoles:
1413
- "view"
1514
existingRoles:
1615
- "some-role"
16+
role:
17+
extraResources:
18+
- apiGroups: ["storage.k8s.io"]
19+
resources: ["storageclasses"]
20+
verbs: ["get", "list", "watch", "update", "patch"]
21+
clusterRole:
22+
extraResources:
23+
- apiGroups: ["storage.k8s.io"]
24+
resources: ["storageclasses"]
25+
verbs: ["get", "list", "watch", "update", "patch"]

charts/capsule/templates/rbac.yaml

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
{{- if or (and $.Values.crds.exclusive $.Values.crds.createRBAC) (not $.Values.crds.exclusive) }}
22
{{- if $.Values.manager.rbac.create }}
3+
{{- with .Values.manager.rbac.clusterRole.extraResources }}
4+
---
5+
kind: ClusterRoleBinding
6+
apiVersion: rbac.authorization.k8s.io/v1
7+
metadata:
8+
name: capsule:{{ include "capsule.fullname" $ }}:extra
9+
labels:
10+
{{- include "capsule.labels" $ | nindent 4 }}
11+
{{- with $.Values.customAnnotations }}
12+
annotations:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
roleRef:
16+
apiGroup: rbac.authorization.k8s.io
17+
kind: ClusterRole
18+
name: capsule:{{ $.Release.Name }}:extra
19+
subjects:
20+
- kind: ServiceAccount
21+
name: {{ include "capsule.serviceAccountName" $ }}
22+
namespace: {{ $.Release.Namespace }}
23+
---
24+
apiVersion: rbac.authorization.k8s.io/v1
25+
kind: ClusterRole
26+
metadata:
27+
name: capsule:{{ $.Release.Name }}:extra
28+
labels:
29+
{{- include "capsule.labels" $ | nindent 4 }}
30+
{{- with $.Values.customAnnotations }}
31+
annotations:
32+
{{- toYaml . | nindent 4 }}
33+
{{- end }}
34+
rules:
35+
{{- toYaml . | nindent 2 }}
36+
{{- end }}
337
---
438
apiVersion: rbac.authorization.k8s.io/v1
539
kind: ClusterRole
@@ -369,6 +403,40 @@ rules:
369403
- update
370404
- patch
371405
- delete
406+
{{- with .Values.manager.rbac.role.extraResources }}
407+
---
408+
kind: RoleBinding
409+
apiVersion: rbac.authorization.k8s.io/v1
410+
metadata:
411+
name: capsule:{{ include "capsule.fullname" $ }}:extra
412+
labels:
413+
{{- include "capsule.labels" $ | nindent 4 }}
414+
{{- with $.Values.customAnnotations }}
415+
annotations:
416+
{{- toYaml . | nindent 4 }}
417+
{{- end }}
418+
roleRef:
419+
apiGroup: rbac.authorization.k8s.io
420+
kind: Role
421+
name: capsule:{{ $.Release.Name }}:extra
422+
subjects:
423+
- kind: ServiceAccount
424+
name: {{ include "capsule.serviceAccountName" $ }}
425+
namespace: {{ $.Release.Namespace }}
426+
---
427+
apiVersion: rbac.authorization.k8s.io/v1
428+
kind: Role
429+
metadata:
430+
name: capsule:{{ $.Release.Name }}:extra
431+
labels:
432+
{{- include "capsule.labels" $ | nindent 4 }}
433+
{{- with $.Values.customAnnotations }}
434+
annotations:
435+
{{- toYaml . | nindent 4 }}
436+
{{- end }}
437+
rules:
438+
{{- toYaml . | nindent 2 }}
439+
{{- end }}
372440
---
373441
apiVersion: rbac.authorization.k8s.io/v1
374442
kind: Role
@@ -388,7 +456,6 @@ rules:
388456
- apiGroups: [""]
389457
resources: ["secrets"]
390458
verbs: ["get", "list", "watch", "create", "update", "patch"]
391-
392459
---
393460
kind: RoleBinding
394461
apiVersion: rbac.authorization.k8s.io/v1

charts/capsule/values.schema.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,14 @@
508508
"rbac": {
509509
"type": "object",
510510
"properties": {
511+
"clusterRole": {
512+
"type": "object",
513+
"properties": {
514+
"extraResources": {
515+
"type": "array"
516+
}
517+
}
518+
},
511519
"create": {
512520
"description": "Specifies whether RBAC resources should be created.",
513521
"type": "boolean"
@@ -520,6 +528,14 @@
520528
"description": "Specifies further cluster roles to be added to the Capsule manager service account.",
521529
"type": "array"
522530
},
531+
"role": {
532+
"type": "object",
533+
"properties": {
534+
"extraResources": {
535+
"type": "array"
536+
}
537+
}
538+
},
523539
"strict": {
524540
"description": "Strongly restrict the RBAC assigned to Capsule Controller. When set to true you must aggregate further permissions by yourself.",
525541
"type": "boolean"

charts/capsule/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ manager:
131131
existingRoles: []
132132
# - namespace-admin
133133

134+
role:
135+
# - Extra resources provided to the capsule controller ServiceAccount. This can be used to grant permissions for custom resources which are not managed by capsule, but still need to be accessed by the controller. When using this option, you need to provide the name of the ClusterRole which will be created with the specified rules and then bind it to the Capsule ServiceAccount.
136+
extraResources: []
137+
138+
clusterRole:
139+
# - Extra resources provided to the capsule controller ServiceAccount. This can be used to grant permissions for custom resources which are not managed by capsule, but still need to be accessed by the controller. When using this option, you need to provide the name of the ClusterRole which will be created with the specified rules and then bind it to the Capsule ServiceAccount.
140+
extraResources: []
141+
# - apiGroups: ["storage.k8s.io"]
142+
# resources: ["storageclasses"]
143+
# verbs: ["get", "list", "watch", "update", "patch"]
144+
134145
# -- Set the controller deployment mode as `Deployment` or `DaemonSet`.
135146
kind: Deployment
136147

0 commit comments

Comments
 (0)