Skip to content

Commit 1767835

Browse files
feat(supervisor): KUBERNETES_WORKER_ENV_FROM_SECRET — envFrom secret on every worker pod
Adds a single env var on the supervisor that names a Kubernetes Secret to mount via `envFrom` on every worker pod the supervisor schedules. All key/value pairs in the secret become env vars on the worker container — resolved by the kubelet at pod creation, so the supervisor never reads the secret values and needs no extra RBAC. Use case: keep task-time secrets (DB URLs, API keys, etc.) in Kubernetes Secrets owned by ops, instead of syncing them through trigger.dev's webapp + database. Single source of truth in K8s; the secret never leaves the K8s plane on its way to a task pod. When the env var is unset (default) the worker pod spec is unchanged — upstream behavior preserved. Configured downstream via: supervisor: extraEnvVars: - name: KUBERNETES_WORKER_ENV_FROM_SECRET value: "trigger-task-secrets" Renders as: spec.containers[0].envFrom = [{ secretRef: { name: "trigger-task-secrets" } }] Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d49241f commit 1767835

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

apps/supervisor/src/env.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ const Env = z
116116
"KUBERNETES_WORKER_CONTAINER_SECURITY_CONTEXT",
117117
{ valueValidator: JsonAny }
118118
),
119+
// Name of a Kubernetes Secret to envFrom-mount into every worker pod's
120+
// container. Pulls every key/value pair in the secret as env vars on
121+
// the worker. Resolved by the kubelet at pod creation time; the
122+
// supervisor never reads the secret values, so this needs no extra
123+
// RBAC. Use case: keep task-time secrets (DB URLs, API keys) in
124+
// Kubernetes rather than syncing them through the trigger.dev webapp.
125+
KUBERNETES_WORKER_ENV_FROM_SECRET: z.string().optional(),
119126
KUBERNETES_IMAGE_PULL_SECRETS: z.string().optional(), // csv
120127
KUBERNETES_EPHEMERAL_STORAGE_SIZE_LIMIT: z.string().default("10Gi"),
121128
KUBERNETES_EPHEMERAL_STORAGE_SIZE_REQUEST: z.string().default("2Gi"),

apps/supervisor/src/workloadManager/kubernetes.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ export class KubernetesWorkloadManager implements WorkloadManager {
139139
...(Object.keys(env.KUBERNETES_WORKER_CONTAINER_SECURITY_CONTEXT).length > 0
140140
? { securityContext: env.KUBERNETES_WORKER_CONTAINER_SECURITY_CONTEXT }
141141
: {}),
142+
...(env.KUBERNETES_WORKER_ENV_FROM_SECRET
143+
? {
144+
envFrom: [
145+
{ secretRef: { name: env.KUBERNETES_WORKER_ENV_FROM_SECRET } },
146+
],
147+
}
148+
: {}),
142149
env: [
143150
{
144151
name: "TRIGGER_DEQUEUED_AT_MS",

0 commit comments

Comments
 (0)