Fernando Correia
03/19/2025, 10:08 PMMarvin
03/19/2025, 10:08 PMdeploy
and flow
functions, among others, to manage deployments. The top-level API includes functions like deploy
, flow
, and task
that may be relevant for setting up your flows and tasks with specific resource requirements.Fernando Correia
03/19/2025, 10:10 PMMarvin
03/19/2025, 10:10 PMfoo
and bar
.
1. Deployment foo
with 1 CPU and 1 GB of RAM:
In the Kubernetes work pool settings, modify the JSON job template to include:
json
{
"job_configuration": {
"containers": [{
"resources": {
"requests": {
"cpu": "1",
"memory": "1Gi"
}
}
}]
}
}
2. Deployment bar
with 2 CPUs and 2 GB of RAM:
Similarly, adjust the job template for the bar
deployment:
json
{
"job_configuration": {
"containers": [{
"resources": {
"requests": {
"cpu": "2",
"memory": "2Gi"
}
}
}]
}
}
These configurations are set in the advanced settings of your Kubernetes work pool. You can find more details in the Prefect Kubernetes Infrastructure Examples documentation.
By setting these configurations, each deployment will have the specified resources allocated when executed.Fernando Correia
03/19/2025, 10:11 PMMarvin
03/19/2025, 10:11 PMprefect.yaml
file with the specified configurations for deployments foo
and bar
, you need to define each deployment with its respective resource requests. Here's an example of how you might structure this file:
yaml
version: 3
deployments:
- name: foo
work_pool:
type: kubernetes
job_configuration:
containers:
- resources:
requests:
cpu: "1"
memory: "1Gi"
flow_location: path/to/foo_flow.py
parameters: {}
- name: bar
work_pool:
type: kubernetes
job_configuration:
containers:
- resources:
requests:
cpu: "2"
memory: "2Gi"
flow_location: path/to/bar_flow.py
parameters: {}
### Explanation:
- version: Specifies the Prefect version.
- deployments: Lists the deployments, foo
and bar
.
- work_pool: Specifies the Kubernetes work pool type and the job configuration for resource requests.
- job_configuration: Contains the containers
section where CPU and memory requests are defined.
- flow_location: Placeholder paths to the flow scripts (foo_flow.py
and bar_flow.py
). Adjust these paths to point to your actual flow scripts.
- parameters: An optional section where you can define any parameters your flows might require.
Make sure to replace path/to/foo_flow.py
and path/to/bar_flow.py
with the actual paths to your flow scripts. This configuration assumes you are using Prefect 3.x and have set up your Kubernetes work pool accordingly.