Rasmus
07/10/2025, 9:19 AM{
"image": "***",
"job_configuration": {
"spec": {
"template": {
"spec": {
"containers": [
{
"resources": {
"limits": {
"cpu": "1000m",
"memory": "1Gi"
},
"requests": {
"cpu": "2000m",
"memory": "512Mi"
}
}
}
]
}
}
}
}
}
However, when i run a deployment, it seems like it overrides the resources i am trying to specify, these are the parameters which are passed to the pod:
resources:
limits:
ephemeral-storage: 1Gi
requests:
cpu: 500m
ephemeral-storage: 1Gi
memory: 2Gi
I suspect that these are the standard values from a k8s work pool. Can you help me figure out why my custom resources are overwritten?Marvin
07/10/2025, 9:19 AMMarvin
07/10/2025, 9:19 AMjson
{
"job_template": {
"apiVersion": "batch/v1",
"kind": "Job",
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "prefect",
"resources": {
"limits": {
"cpu": "1000m",
"memory": "1Gi"
},
"requests": {
"cpu": "2000m",
"memory": "512Mi"
}
}
}
]
}
}
}
}
}
Key differences and recommendations:
1. Use the job_template
key instead of job_configuration
2. Include the complete API version and kind specifications
3. Make sure to specify the container name as "prefect"
4. For GKE Autopilot, ensure your resource requests and limits fall within the allowed ranges:
- CPU requests must be between 0.25 and 28 vCPU
- Memory requests must be between 0.5 GB and 256 GB
You can apply this configuration in two ways:
1. In the work pool configuration (if you want these resources to apply to all deployments using this work pool)
2. In the deployment configuration (if you want these resources to apply to just this specific deployment)
Also, note that GKE Autopilot may add some default values for ephemeral-storage
. This is normal and you can either specify your own value or let it use the defaults.
If you're still seeing your values being overridden after making these changes, you might want to:
1. Check your work pool configuration to ensure there aren't any conflicting default values
2. Verify that your GKE Autopilot cluster's constraints aren't forcing different values
3. Ensure you're applying the configuration at the correct level (work pool vs. deployment)
You can find more details about Kubernetes configuration in Prefect in the documentation.Rasmus
07/10/2025, 9:22 AMMarvin
07/10/2025, 9:22 AMMarvin
07/10/2025, 9:23 AMflow.deploy()
call:
python
hello.deploy(
name="hello-flow-1",
work_pool_name="test-work-pool",
image="europe-west3-docker.pkg.dev/infrastructure-464107/infrastructure-464107-docker-dev/hello2:latest1",
job_variables={
"job_template": {
"apiVersion": "batch/v1",
"kind": "Job",
"spec": {
"template": {
"spec": {
"containers": [{
"name": "prefect", # This is important!
"resources": {
"requests": {
"cpu": "100m",
"memory": "512Mi"
},
"limits": {
"cpu": "1000m",
"memory": "1Gi"
}
}
}]
}
}
}
}
}
)
Key changes from your version:
1. Changed job_configuration
to job_template
2. Added the required Kubernetes API fields (apiVersion
and kind
)
3. Added name: "prefect"
to the container specification
4. Structured the template as a complete Kubernetes job specification
This configuration will properly override the default resources with your specified values. The resources you've specified are:
- CPU request: 100m (0.1 CPU cores)
- CPU limit: 1000m (1 CPU core)
- Memory request: 512Mi
- Memory limit: 1Gi
These values should work fine with GKE Autopilot as they're within the acceptable ranges. If you need to verify that your resources are being applied correctly, you can:
1. Check the deployment configuration in the Prefect UI after deployment
2. Verify the actual pod specifications in your Kubernetes cluster using:
bash
kubectl get pod <pod-name> -o yaml
Remember that if you need to make these resource specifications the default for all deployments using this work pool, you should instead configure them in the work pool settings rather than specifying them in each deploy()
call.Marvin
07/10/2025, 9:27 AMRasmus
07/10/2025, 9:27 AMMarvin
07/10/2025, 9:27 AMflow.deploy()
call:
python
hello.deploy(
name="hello-flow-1",
work_pool_name="test-work-pool",
image="**", # your image URL here
job_variables={
"job_template": { # Changed from job_configuration
"apiVersion": "batch/v1",
"kind": "Job",
"spec": {
"template": {
"spec": {
"containers": [{
"name": "prefect", # Added required name field
"resources": {
"requests": {
"cpu": "100m",
"memory": "512Mi"
},
"limits": {
"cpu": "1000m",
"memory": "1Gi"
}
}
}]
}
}
}
}
}
)
The key changes from your version are:
1. Changed job_configuration
to job_template
2. Added apiVersion
and kind
fields
3. Added the required name: "prefect"
to the container spec
These changes will ensure that your resource specifications are properly applied to the Kubernetes pods when they run. The resources you've specified (100m CPU request, 1000m CPU limit, 512Mi memory request, and 1Gi memory limit) will be used instead of the work pool defaults.
If you're still seeing the resources being overridden after making these changes, you might want to check your work pool configuration in the Prefect UI to ensure there aren't any conflicting settings there.Marvin
07/10/2025, 9:27 AMMarvin
07/10/2025, 9:27 AMflow.deploy()
call with the image redacted:
python
hello.deploy(
name="hello-flow-1",
work_pool_name="test-work-pool",
image="***", # redacted image URL
job_variables={
"job_template": { # Changed from job_configuration
"apiVersion": "batch/v1",
"kind": "Job",
"spec": {
"template": {
"spec": {
"containers": [{
"name": "prefect", # Added required name field
"resources": {
"requests": {
"cpu": "100m",
"memory": "512Mi"
},
"limits": {
"cpu": "1000m",
"memory": "1Gi"
}
}
}]
}
}
}
}
}
)
The key changes from your version are:
1. Changed job_configuration
to job_template
2. Added apiVersion
and kind
fields
3. Added the required name: "prefect"
to the container spec
These changes will ensure that your resource specifications are properly applied to the Kubernetes pods when they run. The resources you've specified (100m CPU request, 1000m CPU limit, 512Mi memory request, and 1Gi memory limit) will be used instead of the work pool defaults.
If you're still seeing the resources being overridden after making these changes, you might want to check your work pool configuration in the Prefect UI to ensure there aren't any conflicting settings there.Rasmus
07/10/2025, 9:38 AMMarvin
07/10/2025, 9:38 AMMarvin
07/10/2025, 9:38 AM***
or <redacted>
when sharing code examples
3. If sensitive information is accidentally shared, you should contact your platform administrator to have it removed
Would you like to continue discussing the Kubernetes resource configuration with properly redacted information?Rasmus
07/10/2025, 9:39 AMMarvin
07/10/2025, 9:39 AMMarvin
07/10/2025, 9:39 AMRasmus
07/10/2025, 10:23 AMfrom_file
for creation.",
"secret_fields": [],
"block_type_slug": "kubernetes-cluster-config",
"block_schema_references": {}
}
},
"description": "Default variables for the Kubernetes worker.\n\nThe schema for this class is used to populate the variables
section of the default\nbase job template."
},
"job_configuration": {
"env": "{{ env }}",
"name": "{{ name }}",
"labels": "{{ labels }}",
"command": "{{ command }}",
"namespace": "{{ namespace }}",
"job_manifest": {
"kind": "Job",
"spec": {
"template": {
"spec": {
"containers": [
{
"env": "{{ env }}",
"args": "{{ command }}",
"name": "prefect-job",
"image": "{{ image }}",
"resources": {
"requests": {
"cpu": "{{ cpu_request }}",
"memory": "{{ memory_request }}"
}
},
"imagePullPolicy": "{{ image_pull_policy }}"
}
],
"completions": 1,
"parallelism": 1,
"restartPolicy": "Never",
"serviceAccountName": "{{ service_account_name }}"
}
},
"backoffLimit": "{{ backoff_limit }}",
"ttlSecondsAfterFinished": "{{ finished_job_ttl }}"
},
"metadata": {
"labels": "{{ labels }}",
"namespace": "{{ namespace }}",
"generateName": "{{ name }}-"
},
"apiVersion": "batch/v1"
},
"stream_output": "{{ stream_output }}",
"cluster_config": "{{ cluster_config }}",
"job_watch_timeout_seconds": "{{ job_watch_timeout_seconds }}",
"pod_watch_timeout_seconds": "{{ pod_watch_timeout_seconds }}"
}
}Marvin
07/10/2025, 10:23 AM