flyte icon indicating copy to clipboard operation
flyte copied to clipboard

[V2] Apply the settings service account to task pods

Open popojk opened this issue 4 weeks ago • 3 comments

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:

  1. runs: applyRunSettings (runs/service/settings_apply.go) does not set RunSpec.security_context.
  2. actions: applyRunSpecToTaskAction (actions/k8s/client.go) does not copy RunSpec.security_context to the TaskAction, and the TaskAction CRD has no field for it.
  3. executor: resolveServiceAccount (executor/pkg/plugin/task_exec_metadata.go) reads only the task template's security_context.run_as.k8s_service_account, then falls back to config.

Proposed change

  1. runs: when RunSpec.security_context.run_as.k8s_service_account is empty and the resolved setting is VALUE, set it from settings. Don't touch other security_context fields.
  2. actions / CRD: add a run-scoped service account field to TaskActionSpec (like PodTemplateName and EnvVars), set it in applyRunSpecToTaskAction, and carry it to child actions in inheritRunContextFromParentTaskAction. Regenerate CRDs (make generate) so the chart and devbox copies match.
  3. 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_account at project scope and check the task pod's spec.serviceAccountName. A task whose template names its own service account keeps it. A child action of the run gets the same service account.

popojk avatar Nov 04 '26 01:11 popojk

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!

runllm avatar Nov 04 '26 01:11 runllm

#take

Chiuuu0209 avatar Nov 04 '26 06:11 Chiuuu0209

Hi @popojk, it looks like this is now covered by #8414 (merged, closes #8241), which overlaps with this issue:

  • applyRunSettings applies security.service_account when the run sets none
  • TaskActionSpec.ServiceAccount carries 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.

Chiuuu0209 avatar Nov 17 '26 05:11 Chiuuu0209