Hi all, how does one specify resource limits for a...
# prefect-community
r
Hi all, how does one specify resource limits for a KubernetesFlowRunner in prefect 2? Previously in prefect 1 you could specify cpu_limit, memory_request, etc... I don't see much documentation on how this work in prefect 2, is there anymore examples of more advanced Kubernetes deployment i can see?
r
You can add a list of customizations - list of JSON 6902 patches to apply to the base Job manifest
e.g
Copy code
[
        { "op": "replace", "path": "/spec/template/spec/containers/0/resources/limits/cpu",  "value": "{{ .Values.cpu }}m" }
]
I have not tried this
I cant get it to work
r
Yea i am having the same issues
@James Sopkin or @Anna Geller any ideas on this. I changed "op": replace to "op": add and I still get the JSON pointer exception.
a
Try this syntax:
Copy code
from prefect.deployments import DeploymentSpec
from prefect.flow_runners import KubernetesFlowRunner

@flow
def my_flow(...):
   ...

DeploymentSpec(
    name="my-flow",
    flow=my_flow,
    flow_runner=KubernetesFlowRunner(
        namespace="my-world",
        image="my/image:mytag",
        customizations=[
            {
                "op": "add",
                "path": "/spec/template/spec/resources",
                "value": {"limits": {"memory": "8Gi", "cpu": "4000m"}},
            }
        ],
    ),
)
gratitude thank you 1
r
@Anna Geller thank you! That syntax worked like a charm. The discourse post is also a great bonus.
🙌 1
r
@Anna Geller aha, thanks for that 👍
🙌 1