Skip to content

feat(PrefectWorkPool): add ServiceAccount support#244

Merged
mitchnielsen merged 3 commits intomainfrom
issue-243
Feb 12, 2026
Merged

feat(PrefectWorkPool): add ServiceAccount support#244
mitchnielsen merged 3 commits intomainfrom
issue-243

Conversation

@mitchnielsen
Copy link
Member

Users deploying PrefectWorkPool resources through GitOps workflows were encountering RBAC permission errors because worker pods always used the namespace's default ServiceAccount. This caused pod and job listing failures with "APIForbiddenError: pods is forbidden" messages.

Added an optional serviceAccountName field to the PrefectWorkPoolSpec that allows users to specify a custom ServiceAccount for worker pods. When not specified, the field defaults to empty string, maintaining backward compatibility by using the namespace's default ServiceAccount.

Changes

  • Added serviceAccountName optional field to PrefectWorkPoolSpec
  • Updated controller to apply the ServiceAccount to worker pod deployments
  • Added helper function to handle default behavior when field is not set
  • Generated updated CRDs with the new field
  • Added three test cases covering custom SA, default SA, and empty string scenarios
  • Updated sample manifests with commented example
  • Regenerated CRD documentation

Testing

All 128 unit tests pass, including 3 new tests specifically for ServiceAccount behavior.

Closes #243

Users deploying PrefectWorkPool resources through GitOps workflows were encountering RBAC permission errors because worker pods always used the namespace's default ServiceAccount. This caused pod and job listing failures with "APIForbiddenError: pods is forbidden" messages.

Added an optional `serviceAccountName` field to the PrefectWorkPoolSpec that allows users to specify a custom ServiceAccount for worker pods. When not specified, the field defaults to empty string, maintaining backward compatibility by using the namespace's default ServiceAccount.

Changes:
- Added `serviceAccountName` optional field to PrefectWorkPoolSpec
- Updated controller to apply the ServiceAccount to worker pod deployments
- Added helper function to handle default behavior when field is not set
- Generated updated CRDs with the new field
- Added three test cases covering custom SA, default SA, and empty string scenarios
- Updated sample manifests with commented example
- Regenerated CRD documentation

Closes #243

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@mitchnielsen mitchnielsen added the feature New feature label Feb 12, 2026
@mitchnielsen mitchnielsen changed the title Add ServiceAccount support to PrefectWorkPool feat(PrefectWorkPool): add ServiceAccount support Feb 12, 2026
The other PrefectWorkPool helpers (Image, EntrypointArguments, ToEnvVars,
etc.) are methods on the type. Move getServiceAccountName to match.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mitchnielsen mitchnielsen marked this pull request as ready for review February 12, 2026 21:02
@mitchnielsen mitchnielsen requested review from a team as code owners February 12, 2026 21:02
@mitchnielsen mitchnielsen merged commit 1d53197 into main Feb 12, 2026
8 checks passed
@mitchnielsen mitchnielsen deleted the issue-243 branch February 12, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request/Question] Ability to configure a custom ServiceAccount for PrefectWorkPool worker pods

2 participants