Skip to content

WorkerPool can set the ServiceAccount of its worker pods - #2219

Merged
Julian Gutierrez Oschmann (juli4n) merged 2 commits into
agent-substrate:mainfrom
danielle-mustillo:danielle-mustillo/workerpool-service-account
Oct 7, 2026
Merged

Julian Gutierrez Oschmann (juli4n) merged 2 commits into
agent-substrate:mainfrom
danielle-mustillo:danielle-mustillo/workerpool-service-account

Conversation

@danielle-mustillo

@danielle-mustillo Danielle Mustillo (danielle-mustillo) commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

A WorkerPool now has spec.template.serviceAccountName. The worker pods run as that ServiceAccount. When the field is omitted, the pods use the namespace's default ServiceAccount, as before.

Some clusters have an admission policy (for example, OPA Gatekeeper) that rejects pods that use the default ServiceAccount. These clusters could not run workers.

Notes for review:

  • The field is *string with MinLength=1, because kube-api-linter requires new optional fields to be pointers. An explicit empty string is rejected.
  • The ServiceAccount must exist in the WorkerPool's namespace. The controller does not create it.

Testing

  • Unit and envtest suites (126 packages), apitool, and the verify scripts. Not run: proto-fmt (no local clang-format).

  • Local kind e2e, envoy dataplane, gVisor: pass, including identity.

  • Tests pass

  • Appropriate changes to documentation are included in the PR (docs/api-guide.md)

Worker pods always ran as the namespace's default ServiceAccount. Clusters
with an admission policy that denies the default ServiceAccount (for
example, OPA Gatekeeper) could not run workers.

Add spec.template.serviceAccountName. The controller also owns the
deprecated spec.serviceAccount alias. The API server copies the name into
the alias and reads the alias back when the name is empty, so without it,
removing the field would keep the old ServiceAccount.

The field is a pointer with MinLength=1 to satisfy the kube-api-linter
optionalfields rule.
When the WorkerPool omits serviceAccountName, set "default" instead of
an empty name. A non-empty name wins over the deprecated serviceAccount
alias, so the controller no longer needs to own the alias.
@juli4n

Copy link
Copy Markdown
Collaborator

It's a bit unfortunate that we need this field as workers should not need a KSA identity, so this is just to make your policy enforcement happy. That being said, I don't see any other simpler option.

@EItanya

Copy link
Copy Markdown
Collaborator

It's a bit unfortunate that we need this field as workers should not need a KSA identity, so this is just to make your policy enforcement happy. That being said, I don't see any other simpler option.

I think the question for me is whether there is a downside to this, and I don't think so. I've heard this requirement come up multiple times, and I think requiring the user to build their own controller for this is overly burdensome.

In that light I'm ok with it

@maxsmythe Max Smythe (maxsmythe) added area/identity kind/bug Something isn't working / bugfixes labels Oct 7, 2026
Merged via the queue into agent-substrate:main with commit 92b74c0 Oct 7, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/identity kind/bug Something isn't working / bugfixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants