Pods, Jobs, or Services for AI agents?
Choose the Kubernetes execution shape for an AI agent by separating logical task identity from Pods, Jobs, Services, workflows, and sandbox lifecycles.

An agent is a logical application role. A Pod is an execution environment. Treating them as the same thing is convenient for a prototype, but it couples task identity, state, scaling, and cost to the lifetime of one replaceable Kubernetes object.
The better question is not “Should an agent run in a Pod?” Containerized agent code ultimately does. The question is which workload resource should own those Pods, and whether one logical agent needs a dedicated process at all.
Do not make the Pod the task record
Kubernetes describes a Pod as the smallest deployable compute object and recommends using workload resources to manage Pods. Pods are relatively ephemeral: a controller can replace one with a new Pod that has a different identity.
Give each logical task an application-level ID that survives those replacements. Record execution attempts beneath it, and store progress in a durable backend. Pod name, container ID, run UUID, framework thread, and user request ID can all be useful correlations, but none should silently substitute for the task identity.
This separation makes several operating models possible:
- one service process can advance many logical tasks;
- one task can use several bounded Jobs;
- a task can stop consuming compute while it waits for approval;
- a replacement worker can resume committed state; and
- a warm execution pool can serve many short-lived actors without one idle Pod per actor.
Use a Deployment for continuously available workers
A Deployment is a good starting point for a stateless request endpoint, dispatcher, or worker pool that should remain available. Pair it with a Service when other components need a stable network endpoint.
This shape works well when the application can externalize task state and distribute requests among interchangeable replicas. Examples include an agent API, a model gateway, a retrieval service, or a pool of workers that claim queued tasks.
Define graceful shutdown and draining. During a rollout, a worker should stop claiming new tasks, finish or checkpoint current steps, and release ownership before it exits. A readiness probe can remove a Pod from service traffic, but it does not implement application-level draining by itself.
Autoscaling should follow a meaningful demand signal. CPU can be a poor proxy when workers spend most of their time waiting for model or tool responses. Queue age, runnable task count, active model calls, or an application concurrency metric may describe the pressure more directly.
Use a Job for bounded execution
A Kubernetes Job represents work that runs to completion. It fits report generation, repository analysis, batch document processing, evaluations, and other tasks with a clear terminal result.
Jobs provide completion tracking, retry configuration, parallelism, and cleanup controls. They do not make an agent task exactly-once. Kubernetes documentation notes that the same program can sometimes be started twice, even when only one completion is requested. The application must make retries safe and reconcile effects whose outcome is uncertain.
Use a Job when independent placement, resource isolation, or failure accounting is more valuable than avoiding startup overhead. Pass a durable task reference to the container instead of embedding the entire task state in environment variables. On startup, the worker should claim the intended attempt and load the last committed checkpoint.
For recurring maintenance or evaluation, a CronJob can create Jobs on a schedule. Decide how missed or overlapping schedules are handled, and keep the scheduled trigger separate from the identity of each resulting task.
Combine a Service with Jobs for mixed workloads
Many agent applications need both a responsive interface and asynchronous execution. A service can validate and accept the request, commit a task record, and return an identifier. A dispatcher can then create or submit a bounded workload for the expensive portion.
This design lets the public endpoint scale independently from code execution. It also gives long tasks explicit deadlines, resources, retries, and output collection. The tradeoff is a more deliberate state protocol: acceptance, dispatch, cancellation, completion, and artifact availability must all be recorded.
Do not acknowledge acceptance until the task is durable. If the client retries after a network failure, deduplicate by a stable request identity. If a user cancels, stop new dispatch first, then account for already-running tool calls and child tasks.
Use workflows for known dependencies
A workflow or DAG is useful when dependencies are known in advance: prepare a dataset, run agent cases, evaluate outputs, aggregate results, and publish a report. It provides a visible execution graph and separates failure domains between steps.
Keep the model-driven loop inside the component that owns its state unless the workflow engine explicitly supports the required dynamic behavior and recovery semantics. Turning every reasoning step into a separate Kubernetes Job can add orchestration overhead without creating a useful operational boundary.
Use the workflow to coordinate stable units of work. Record non-deterministic model and tool results before later steps depend on them. The reliable pipeline orchestration guide covers dependencies, caching, placement, and retries for these graphs.
Use a sandbox lifecycle for isolated stateful sessions
Some agents need a stable workspace rather than a continuously available replica or a simple run-to-completion Job. A coding agent may create files, pause for review, resume later, and require stronger isolation because it executes generated commands.
The Kubernetes SIG Apps Agent Sandbox project is developing Kubernetes-native abstractions for isolated, stateful singleton workloads. Its design includes a Sandbox custom resource, stable identity, suspension and resumption, optional stronger runtimes, and warm-pool extensions. It is an evolving project, so check its current maturity and release documentation before selecting it for a production boundary.
The useful architectural lesson is broader than one implementation: model the workspace lifecycle explicitly. Define how it is created, claimed, paused, resumed, reset, retained, and destroyed. Do not approximate that lifecycle with an unmanaged Pod and a collection of cleanup scripts.
Consider worker pools for short, bursty actors
If thousands of logical agents are mostly idle or execute for only a few seconds, one dedicated Pod per agent can waste capacity and amplify startup overhead. A fixed or elastic pool of workers can host many logical actors while the application layer manages actor placement and state.
Pooling changes the isolation and accounting model. Decide whether a worker handles one actor at a time, how writable state is reset, which credentials are attached, and whether data from one task can influence another. Stronger isolation may require separate sandbox instances even when a shared pool would be cheaper.
Use measurements rather than a universal rule. Compare cold-start time, resume latency, idle cost, task duration, failure recovery, and the trust level of the code being executed.
Choose with a workload matrix
| Requirement | Deployment and Service | Job | Workflow or DAG | Stateful sandbox | Worker pool |
|---|---|---|---|---|---|
| Continuous endpoint | Strong fit | Poor fit | Not the endpoint | Possible but specialized | Strong fit behind a service |
| Bounded completion | Application-defined | Strong fit | Strong fit across steps | Application-defined | Application-defined |
| Independent resource placement | Per replica class | Per task | Per step | Per sandbox | Per pool or worker |
| Long idle wait | Holds capacity unless state is released | Poor fit if left running | Suspend and redispatch | Designed for pause/resume | Logical task can release a worker |
| Untrusted code | Requires added isolation | Requires added isolation | Depends on each step | Primary use case | Requires strict reset or sandboxing |
| Startup-sensitive interaction | Warm replicas | Cold-start tradeoff | Usually background | Warm pool may help | Strong fit |
The answer can differ within one application. A coordinator may use a Deployment, retrieval may use a Service, a long analysis may use a Job, evaluations may use a DAG, and command execution may use an isolated sandbox.
Express the choice in Polyaxon
Polyaxon components can define jobs for bounded work and services for long-running endpoints and interactive environments. Use DAG operations for explicit supporting dependencies.
Apply termination settings to bound attempts, duration, and cleanup. Pair those infrastructure controls with application checkpoints and idempotency. A restarted container only becomes a resumed task when the startup path loads the intended state and decides what may run next.
Polyaxon sandboxes expose process and filesystem access inside a service run. They are an interaction interface, not a separate isolation runtime. Configure the underlying service's image, identity, mounts, resources, security context, and network policy for the trust level of the task.
Commercial queues can route and limit workloads by team or priority. The guide to operating long-running agents explains how queue delay, provider limits, warm capacity, and human waits affect that operating model.
Test the lifecycle, not just startup
For each execution shape, exercise the transitions that define it: duplicate submission, Pod replacement, node loss, rollout, timeout, cancellation, human wait, failed artifact upload, and an external action with an unknown result.
The right Kubernetes resource is the one whose lifecycle matches the infrastructure work. The logical agent remains an application concept above it, with its own identity, state, authority, and evidence.