Kubernetes Jobs¶
Kubernetes Jobs are for isolated pod-per-task execution. Wove creates a Job, injects the payload into WOVE_BACKEND_PAYLOAD, and the container runs python -m wove.backend_worker.
Use When¶
Each task should run in a fresh pod.
Work needs Kubernetes scheduling, image isolation, service accounts, or pod-level resource control.
A long-lived queue worker is not the right deployment shape.
Execution Shape¶
Wove builds a Kubernetes Job object.
The Job receives the payload as the
WOVE_BACKEND_PAYLOADenvironment variable.The container runs
python -m wove.backend_worker.The worker posts Wove completion events back to the callback URL.
Dependency¶
Install dispatch support and the Kubernetes client in the submitting process. The worker image must also include Wove with dispatch support.
pip install "wove[dispatch]" kubernetes
Configure Wove¶
import wove
wove.config(
default_environment="kubernetes_jobs",
environments={
"kubernetes_jobs": {
"executor": "kubernetes_jobs",
"executor_config": {
"namespace": "jobs",
"image": "registry.example.com/myapp-worker:latest",
"callback_token": "shared-secret",
"callback_url": "https://wove-runner.internal/wove/events/shared-secret",
},
}
},
)
The image must contain Wove, your application code, and a Python runtime that can import the serialized task dependencies.
Default Container Command¶
python -m wove.backend_worker
Custom Job Shape¶
Use job_factory when the cluster needs custom labels, service accounts, resource limits, volumes, sidecars, or scheduling settings.
import wove
def make_job(payload, frame, config):
...
wove.config(
environments={
"jobs": {
"executor": "kubernetes_jobs",
"executor_config": {
"namespace": "jobs",
"job_factory": make_job,
},
}
},
)
Options¶
Key |
Effect |
|---|---|
|
Kubernetes namespace. Defaults to |
|
Image used by the default Job factory. |
|
Container command. Defaults to |
|
Callable that returns a Kubernetes Job object. |
|
Existing |
|
Set to |
|
Use in-cluster config when loading Kubernetes config. |
|
Options passed to the Kubernetes config loader. |
|
Default Job backoff limit. |
|
Generated Job name prefix. Defaults to |