Skip to content

Commit af77d3c

Browse files
committed
Add serviceAccountTokenCreationRoles helm chart array value
The array allows users to supply KEDA with the names and namespaces of service accounts that they would like the keda-operator to request tokens from. These service account tokens are then used in turn for the boundServiceAccountToken trigger source. Signed-off-by: Max Cao <[email protected]>
1 parent 285f693 commit af77d3c

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

keda/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ their default values.
141141
| `operator.revisionHistoryLimit` | int | `10` | ReplicaSets for this Deployment you want to retain (Default: 10) |
142142
| `permissions.operator.restrict.namesAllowList` | list | `[]` | Array of strings denoting what secrets the KEDA operator will be able to read, this takes into account also the configured `watchNamespace`. the default is an empty array -> no restriction on the secret name |
143143
| `permissions.operator.restrict.secret` | bool | `false` | Restrict Secret Access for KEDA operator if true, KEDA operator will be able to read only secrets in {{ .Release.Namespace }} namespace |
144+
| `permissions.operator.restrict.serviceAccountTokenCreationRoles` | list | `[]` | Creates roles and rolebindings from namespaced service accounts in the array which allow the KEDA operator to request service account tokens |
144145
| `podAnnotations.keda` | object | `{}` | Pod annotations for KEDA operator |
145146
| `podDisruptionBudget.operator` | object | `{}` | Capability to configure [Pod Disruption Budget] |
146147
| `podLabels.keda` | object | `{}` | Pod labels for KEDA operator |

keda/templates/manager/clusterrole.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,51 @@ rules:
210210
- list
211211
- watch
212212
{{- end -}}
213+
{{- if .Values.permissions.operator.restrict.serviceAccountTokenCreationRoles }}
214+
{{- range $r := .Values.permissions.operator.restrict.serviceAccountTokenCreationRoles }}
215+
---
216+
apiVersion: rbac.authorization.k8s.io/v1
217+
kind: Role
218+
metadata:
219+
{{- with $.Values.additionalAnnotations }}
220+
annotations:
221+
{{- toYaml . | nindent 4 }}
222+
{{- end }}
223+
labels:
224+
app.kubernetes.io/name: {{ $.Values.operator.name }}
225+
{{- include "keda.labels" $ | indent 4 }}
226+
name: {{ $.Values.operator.name }}-token-creator-{{ $r.name }}
227+
namespace: {{ $r.namespace }}
228+
rules:
229+
- apiGroups:
230+
- ""
231+
resources:
232+
- serviceaccounts/token
233+
verbs:
234+
- create
235+
resourceNames:
236+
- {{ $r.name }}
237+
---
238+
apiVersion: rbac.authorization.k8s.io/v1
239+
kind: RoleBinding
240+
metadata:
241+
{{- with $.Values.additionalAnnotations }}
242+
annotations:
243+
{{- toYaml . | nindent 4 }}
244+
{{- end }}
245+
labels:
246+
app.kubernetes.io/name: {{ $.Values.operator.name }}
247+
{{- include "keda.labels" $ | indent 4 }}
248+
name: {{ $.Values.operator.name }}-token-creator-{{ $r.name }}
249+
namespace: {{ $r.namespace }}
250+
roleRef:
251+
apiGroup: rbac.authorization.k8s.io
252+
kind: Role
253+
name: {{ $.Values.operator.name }}-token-creator-{{ $r.name }}
254+
subjects:
255+
- kind: ServiceAccount
256+
name: {{ $.Values.operator.name }}
257+
namespace: {{ $.Release.Namespace }}
258+
{{- end }}
259+
{{- end }}
213260
{{- end -}}

keda/values.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,12 @@ permissions:
846846
# also the configured `watchNamespace`.
847847
# the default is an empty array -> no restriction on the secret name
848848
namesAllowList: []
849+
# -- Creates roles and rolebindings from namespaced service accounts in the array which allow the KEDA operator
850+
# to request service account tokens for use with the boundServiceAccountToken trigger source.
851+
# If the namespace does not exist, this will cause the helm chart installation to fail.
852+
serviceAccountTokenCreationRoles: []
853+
# - name: myServiceAccount
854+
# namespace: myServiceAccountNamespace
849855

850856
# -- Array of extra K8s manifests to deploy
851857
extraObjects: []
@@ -867,3 +873,4 @@ customManagedBy: ""
867873
# -- Enable service links in pods. Although enabled, mirroring k8s default, it is highly recommended to disable,
868874
# due to its legacy status [Legacy container links](https://docs.docker.com/engine/network/links/)
869875
enableServiceLinks: true
876+

0 commit comments

Comments
 (0)