Skip to content

Commit 87b6716

Browse files
authored
fix(helm): support webapp serviceAccount annotations for IRSA (#3429)
Mirrors the existing `supervisor.serviceAccount` pattern onto webapp so operators can annotate the SA (IRSA `eks.amazonaws.com/role-arn`, Workload Identity, etc.) or bring their own SA. Without this, `webapp.serviceAccount.annotations` isn't exposed and operators have to patch the SA out-of-band. ```yaml webapp: serviceAccount: create: true name: "" annotations: eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/trigger-webapp ``` Three pieces, same as supervisor: - `webapp.serviceAccount.create` toggle on the SA block - `webapp.serviceAccount.annotations` + `name` values - `trigger-v4.webappServiceAccountName` helper, used by the SA, the token-syncer RoleBinding subject, and the Deployment's `serviceAccountName` Role + RoleBinding are left unguarded (matching supervisor's shape where `rbac.create` is a separate toggle from `serviceAccount.create`) - BYO-SA users take on the responsibility of ensuring the SA they supply has the permissions the RoleBinding grants. Verified with `helm template` against default values, an IRSA annotation override, and `create: false` with a custom name.
1 parent fc71e7d commit 87b6716

5 files changed

Lines changed: 43 additions & 6 deletions

File tree

.github/workflows/pr_checks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
paths-ignore:
77
- "docs/**"
88
- ".changeset/**"
9+
- "hosting/**"
910

1011
concurrency:
1112
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

hosting/k8s/helm/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: trigger
33
description: The official Trigger.dev Helm chart
44
type: application
5-
version: 4.0.5
5+
version: 4.0.6
66
appVersion: v4.0.4
77
home: https://trigger.dev
88
sources:

hosting/k8s/helm/templates/_helpers.tpl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,34 @@ http://{{ include "trigger-v4.fullname" . }}-supervisor:{{ .Values.supervisor.se
521521
{{- end }}
522522

523523
{{/*
524-
Create the name of the supervisor service account to use
524+
Create the name of the supervisor service account to use.
525+
When create is false, name must be set explicitly - falling back to the namespace's
526+
default ServiceAccount would silently grant it the RoleBinding's permissions.
525527
*/}}
526528
{{- define "trigger-v4.supervisorServiceAccountName" -}}
527529
{{- if .Values.supervisor.serviceAccount.create }}
528530
{{- default (printf "%s-supervisor" (include "trigger-v4.fullname" .)) .Values.supervisor.serviceAccount.name }}
529531
{{- else }}
530-
{{- default "default" .Values.supervisor.serviceAccount.name }}
532+
{{- if not .Values.supervisor.serviceAccount.name }}
533+
{{- fail "supervisor.serviceAccount.name must be set when supervisor.serviceAccount.create is false" }}
534+
{{- end }}
535+
{{- .Values.supervisor.serviceAccount.name }}
536+
{{- end }}
537+
{{- end }}
538+
539+
{{/*
540+
Create the name of the webapp service account to use.
541+
When create is false, name must be set explicitly - falling back to the namespace's
542+
default ServiceAccount would silently grant it the token-syncer RoleBinding's permissions.
543+
*/}}
544+
{{- define "trigger-v4.webappServiceAccountName" -}}
545+
{{- if .Values.webapp.serviceAccount.create }}
546+
{{- default (printf "%s-webapp" (include "trigger-v4.fullname" .)) .Values.webapp.serviceAccount.name }}
547+
{{- else }}
548+
{{- if not .Values.webapp.serviceAccount.name }}
549+
{{- fail "webapp.serviceAccount.name must be set when webapp.serviceAccount.create is false" }}
550+
{{- end }}
551+
{{- .Values.webapp.serviceAccount.name }}
531552
{{- end }}
532553
{{- end }}
533554

hosting/k8s/helm/templates/webapp.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
{{- if .Values.webapp.serviceAccount.create }}
12
apiVersion: v1
23
kind: ServiceAccount
34
metadata:
4-
name: {{ include "trigger-v4.fullname" . }}-webapp
5+
name: {{ include "trigger-v4.webappServiceAccountName" . }}
56
labels:
67
{{- $component := "webapp" }}
78
{{- include "trigger-v4.componentLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 4 }}
9+
{{- with .Values.webapp.serviceAccount.annotations }}
10+
annotations:
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
{{- end }}
814
---
915
apiVersion: rbac.authorization.k8s.io/v1
1016
kind: Role
@@ -27,7 +33,7 @@ metadata:
2733
{{- include "trigger-v4.componentLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 4 }}
2834
subjects:
2935
- kind: ServiceAccount
30-
name: {{ include "trigger-v4.fullname" . }}-webapp
36+
name: {{ include "trigger-v4.webappServiceAccountName" . }}
3137
namespace: {{ .Release.Namespace }}
3238
roleRef:
3339
kind: Role
@@ -56,7 +62,7 @@ spec:
5662
labels:
5763
{{- include "trigger-v4.componentSelectorLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 8 }}
5864
spec:
59-
serviceAccountName: {{ include "trigger-v4.fullname" . }}-webapp
65+
serviceAccountName: {{ include "trigger-v4.webappServiceAccountName" . }}
6066
{{- with .Values.global.imagePullSecrets }}
6167
imagePullSecrets:
6268
{{- toYaml . | nindent 8 }}

hosting/k8s/helm/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ webapp:
208208
runReplication:
209209
logLevel: "info" # one of: log, error, warn, info, debug
210210

211+
# ServiceAccount configuration
212+
serviceAccount:
213+
create: true
214+
# Name of the ServiceAccount to use. Required when create is false - otherwise
215+
# the token-syncer RoleBinding would bind to the namespace's "default" SA.
216+
name: ""
217+
# Annotations to add to the ServiceAccount (e.g. eks.amazonaws.com/role-arn for IRSA)
218+
annotations: {}
219+
211220
# Observability configuration (OTel)
212221
observability:
213222
tracing:

0 commit comments

Comments
 (0)