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 <macao@redhat.com>
This commit is contained in:
Max Cao 2025-02-03 19:33:51 -08:00
parent 285f693b92
commit af77d3ca6b
No known key found for this signature in database
GPG Key ID: 4EAEC3318EC211D2
3 changed files with 55 additions and 0 deletions

View File

@ -141,6 +141,7 @@ their default values.
| `operator.revisionHistoryLimit` | int | `10` | ReplicaSets for this Deployment you want to retain (Default: 10) |
| `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 |
| `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 |
| `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 |
| `podAnnotations.keda` | object | `{}` | Pod annotations for KEDA operator |
| `podDisruptionBudget.operator` | object | `{}` | Capability to configure [Pod Disruption Budget] |
| `podLabels.keda` | object | `{}` | Pod labels for KEDA operator |

View File

@ -210,4 +210,51 @@ rules:
- list
- watch
{{- end -}}
{{- if .Values.permissions.operator.restrict.serviceAccountTokenCreationRoles }}
{{- range $r := .Values.permissions.operator.restrict.serviceAccountTokenCreationRoles }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
{{- with $.Values.additionalAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ $.Values.operator.name }}
{{- include "keda.labels" $ | indent 4 }}
name: {{ $.Values.operator.name }}-token-creator-{{ $r.name }}
namespace: {{ $r.namespace }}
rules:
- apiGroups:
- ""
resources:
- serviceaccounts/token
verbs:
- create
resourceNames:
- {{ $r.name }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
{{- with $.Values.additionalAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ $.Values.operator.name }}
{{- include "keda.labels" $ | indent 4 }}
name: {{ $.Values.operator.name }}-token-creator-{{ $r.name }}
namespace: {{ $r.namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ $.Values.operator.name }}-token-creator-{{ $r.name }}
subjects:
- kind: ServiceAccount
name: {{ $.Values.operator.name }}
namespace: {{ $.Release.Namespace }}
{{- end }}
{{- end }}
{{- end -}}

View File

@ -846,6 +846,12 @@ permissions:
# also the configured `watchNamespace`.
# the default is an empty array -> no restriction on the secret name
namesAllowList: []
# -- Creates roles and rolebindings from namespaced service accounts in the array which allow the KEDA operator
# to request service account tokens for use with the boundServiceAccountToken trigger source.
# If the namespace does not exist, this will cause the helm chart installation to fail.
serviceAccountTokenCreationRoles: []
# - name: myServiceAccount
# namespace: myServiceAccountNamespace
# -- Array of extra K8s manifests to deploy
extraObjects: []
@ -867,3 +873,4 @@ customManagedBy: ""
# -- Enable service links in pods. Although enabled, mirroring k8s default, it is highly recommended to disable,
# due to its legacy status [Legacy container links](https://docs.docker.com/engine/network/links/)
enableServiceLinks: true