[V2] Apply the settings service account to task pods
Part of #7932.
Problem
security.service_account is stored and resolved by the settings service but never used. Task pods run under the task template's service account or the executor's DefaultK8sServiceAccount, whatever settings say.
Where
The value has to cross three components, and none of them carries it today:
- runs:
applyRunSettings(runs/service/settings_apply.go) does not setRunSpec.security_context. - actions:
applyRunSpecToTaskAction(actions/k8s/client.go) does not copyRunSpec.security_contextto the TaskAction, and the TaskAction CRD has no field for it. - executor:
resolveServiceAccount(executor/pkg/plugin/task_exec_metadata.go) reads only the task template'ssecurity_context.run_as.k8s_service_account, then falls back to config.
Proposed change
- runs: when
RunSpec.security_context.run_as.k8s_service_accountis empty and the resolved setting isVALUE, set it from settings. Don't touch othersecurity_contextfields. - actions / CRD: add a run-scoped service account field to
TaskActionSpec(likePodTemplateNameandEnvVars), set it inapplyRunSpecToTaskAction, and carry it to child actions ininheritRunContextFromParentTaskAction. Regenerate CRDs (make generate) so the chart and devbox copies match. - executor: resolve in this order: task template → run (request or settings) →
DefaultK8sServiceAccount.
Acceptance
- Unit tests for each layer, including the resolution order in the executor.
- On a devbox: set
service_accountat project scope and check the task pod'sspec.serviceAccountName. A task whose template names its own service account keeps it. A child action of the run gets the same service account.
The proposed precedence matches the executor’s current behavior with a run-level fallback inserted: task-template service account first, then run context, then DefaultK8sServiceAccount. The existing executor test confirms task-template values override the configured default and that the default is used when the template has none (executor service-account tests).
The settings RFC lists security.service_account as the Kubernetes service account for task pods, but the supplied sources do not document the proposed RunSpec → TaskAction/CRD propagation or its implementation. The issue’s missing-account behavior is also not addressed by those sources (Settings Service RFC). Would you like more detail?
Sources:
This is an AI-generated response and your feedback is appreciated! Please leave a 👍 if this is helpful and 👎 if it is not.
Mention @herald to ask follow-up questions. See runllm.com for more!
#take
Hi @popojk, it looks like this is now covered by #8414 (merged, closes #8241), which overlaps with this issue:
applyRunSettingsappliessecurity.service_accountwhen the run sets noneTaskActionSpec.ServiceAccountcarries it to the root action and child actions- it is written into the task template, so the executor picks it up (a task-level service account still takes precedence)
So I think this can be closed as a duplicate of #8241. Could you confirm? If there's other settings-related work left (e.g. the settings docs page), I'd be happy to pick it up.