Jordy Vargas
04/10/2026, 2:37 PMMarvin
04/10/2026, 2:37 PMMarvin
04/10/2026, 2:40 PMprefect work-pool get-default-base-job-template --type kubernetes > base.json
# edit base.json, then
prefect work-pool update --base-job-template base.json my-k8s-pool
- Example base template fragment (JSON) that adds resources and exposes variables:
{
"variables": {
"cpu_request": {
"title": "CPU Request",
"type": "string",
"default": null
},
"cpu_limit": {
"title": "CPU Limit",
"type": "string",
"default": null
},
"memory_request": {
"title": "Memory Request",
"type": "string",
"default": null
},
"memory_limit": {
"title": "Memory Limit",
"type": "string",
"default": null
}
},
"job_configuration": {
"job_manifest": {
"apiVersion": "batch/v1",
"kind": "Job",
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "prefect-job",
"image": "{{ image }}",
"args": "{{ command }}",
"env": "{{ env }}",
"resources": {
"requests": {
"cpu": "{{ cpu_request }}",
"memory": "{{ memory_request }}"
},
"limits": {
"cpu": "{{ cpu_limit }}",
"memory": "{{ memory_limit }}"
}
}
}
],
"restartPolicy": "Never"
}
}
}
}
}
}
- If you prefer static defaults, you can replace the {{ ... }} with literal values like "500m" or "1Gi".
2) Override per deployment (prefect.yaml)
- Add job variables under the deployment’s work_pool:
deployments:
- name: heavy-flow
entrypoint: flows/heavy.py:flow
work_pool:
name: kubernetes
job_variables:
cpu_request: "2"
cpu_limit: "4"
memory_request: "2Gi"
memory_limit: "4Gi"
- Deploy with:
prefect deploy -n heavy-flow
3) Override per run (one-off)
- CLI:
prefect deployment run "flow-name/deployment-name" \
--job-variable cpu_request=2 \
--job-variable cpu_limit=4 \
--job-variable memory_request=1Gi \
--job-variable memory_limit=2Gi
- UI: Deployment → Run → Custom run → add the same keys in Job Variables.
Notes
- Precedence: run overrides > deployment job_variables > work pool base template > Kubernetes defaults.
- Use Kubernetes quantity formats (CPU: 500m, 1, 2; Memory: 512Mi, 1Gi).
- Make sure your Kubernetes base job template actually references the variables you plan to set.
- Helpful commands we verified:
- List pools: prefect work-pool ls
- Inspect a pool: prefect work-pool inspect my-k8s-pool
- Get default base template: prefect work-pool get-default-base-job-template --type kubernetes
- Update base template: prefect work-pool update --base-job-template base.json my-k8s-pool
Docs
- Run flows on Kubernetes
- Customize base job templates
- Override job variables
- Manage work pools
If you tell me whether you want global defaults or per-deployment/per-run limits, I can tailor an example exactly to your setup (and include any other k8s fields like node selectors or tolerations).