Skip to content

feat(supervisor): parameterize worker pod annotations, securityContext, SA, envFrom#3758

Closed
ConProgramming wants to merge 6 commits into
triggerdotdev:mainfrom
GovSignals:upstream-pr/supervisor-worker-pod-params
Closed

feat(supervisor): parameterize worker pod annotations, securityContext, SA, envFrom#3758
ConProgramming wants to merge 6 commits into
triggerdotdev:mainfrom
GovSignals:upstream-pr/supervisor-worker-pod-params

Conversation

@ConProgramming
Copy link
Copy Markdown

Summary

Parameterizes worker pod metadata, securityContext, ServiceAccount, and envFrom-Secret via five new optional env vars on the supervisor process, plus matching Helm values. Lets operators configure compliance-required pod settings (annotations, runAsNonRoot, capabilities.drop, seccompProfile, etc.) without patching the supervisor image.

Discovered while rebasing our trigger.dev fork for a FedRAMP environment — Red Hat OpenShift's restricted SCC + pod-security admission policy reject worker pods that don't carry these settings.

Changes

  • New env vars on supervisor: KUBERNETES_WORKER_POD_ANNOTATIONS, _POD_SECURITY_CONTEXT, _CONTAINER_SECURITY_CONTEXT, _SERVICE_ACCOUNT, _ENV_FROM_SECRET (all optional, JSON-encoded for structured ones)
  • envUtil.ts helper for JSON parsing + Zod validation, with tests
  • workloadManager/kubernetes.ts applies parsed values to V1Pod spec
  • Helm chart: supervisor.yaml emits the env vars when corresponding values are set; new supervisor.config.kubernetes.workerPod* keys in values.yaml

Test plan

  • Unit tests for envUtil JSON parsing (success, malformed JSON, schema mismatch)
  • Helm template renders correctly with values set + unset
  • Manually verified against a real OpenShift cluster: worker pods now schedule with the expected securityContext applied

Notes

  • Defaults preserve current behavior — no behavior change for anyone not setting the new values.
  • This is PR 1 of 5 from a fork rebase; the others (helm extras, DEPLOY_IMAGE_OVERRIDE warning, s3.useIam, entrypoint migrate subcommand) are separate.

Made with Cursor

Made with Cursor

ConProgramming and others added 6 commits March 25, 2026 18:53
Merge upstream main into our main
…t, SA, envFrom

The Kubernetes workload manager now reads five new env vars from the
supervisor process and applies them to every spawned worker pod:

  - KUBERNETES_WORKER_POD_ANNOTATIONS         (JSON, Record<string,string>)
  - KUBERNETES_WORKER_POD_SECURITY_CONTEXT    (JSON, V1PodSecurityContext)
  - KUBERNETES_WORKER_CONTAINER_SECURITY_CONTEXT (JSON, V1SecurityContext)
  - KUBERNETES_WORKER_SERVICE_ACCOUNT         (string, SA name)
  - KUBERNETES_WORKER_ENV_FROM_SECRET         (string, Secret name)

All five are optional. When unset, behavior matches today.

Lets compliance-sensitive deployments (Red Hat OpenShift, FedRAMP/IL5
environments, restricted PSA namespaces) configure worker pods through
the Helm chart instead of patching the supervisor image. Also unblocks
operators who need worker pods to:

  - Carry custom annotations (e.g. service mesh sidecar opt-out, audit tags)
  - Run under specific UIDs / capabilities / seccomp profiles
  - Use a non-default ServiceAccount (e.g. for IRSA / Workload Identity)
  - Inherit a batch of env vars from a Secret via envFrom

Includes envUtil helper + tests for JSON parsing of the structured envs.

The supervisor.yaml Helm template emits these env vars from values when set;
schema added under supervisor.config.kubernetes.* in values.yaml.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 26, 2026

⚠️ No Changeset found

Latest commit: 450049c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

Hi @ConProgramming, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this May 26, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b74276ca-07a6-4567-ae82-46f42f14f22d

📥 Commits

Reviewing files that changed from the base of the PR and between 37eeaa3 and 450049c.

📒 Files selected for processing (6)
  • apps/supervisor/src/env.ts
  • apps/supervisor/src/envUtil.test.ts
  • apps/supervisor/src/envUtil.ts
  • apps/supervisor/src/workloadManager/kubernetes.ts
  • hosting/k8s/helm/templates/supervisor.yaml
  • hosting/k8s/helm/values.yaml

Walkthrough

This PR extends Kubernetes worker pod configuration by introducing reusable JSON environment variable parsing schemas, adding new supervisor environment variables for worker service accounts, pod annotations, and security contexts, integrating these configurations into the KubernetesWorkloadManager to conditionally apply settings to pod specs, and exposing the new options through Helm chart values and templates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant