Hello <@ULVA73B9P>, I want to add annotations to m...
# ask-marvin
a
Hello @Marvin, I want to add annotations to my workpool job configurations. I am attempting to add it like this: "annotations": { "type": "object", "title": "Annotations", "default": { "cluster-autoscaler.kubernetes.io/safe-to-evict": "false" }, "description": "Annotations applied to infrastructure created by a worker.", "additionalProperties": { "type": "string" } }, Will this work?
m
Your method for adding annotations to your workpool job configurations isn't directly addressed in the available Prefect documentation or examples. However, from the information found, it appears you may need to follow the approach used for customizations in KubernetesJob infrastructure blocks. Here’s a generalized approach based on what I’ve gathered:
Copy code
python
customizations = [
    {
        "op": "add",
        "path": "/metadata/annotations",
        "value": {
            "<http://cluster-autoscaler.kubernetes.io/safe-to-evict|cluster-autoscaler.kubernetes.io/safe-to-evict>": "false"
        }
    }
]

k8s_job = KubernetesJob(
    namespace=namespace,
    image=image_name,
    customizations=customizations,
)
To confirm this, please visit the respective Prefect documentation links: 1. Work Pools 2. KubernetesJob Infrastructure If you need more detailed guidance catered to your exact query, it might be helpful to reach out to the Prefect community or check for more recent updates in the documentation.
n
yeah i think you're on the right track, marvin is wrong to use the deprecated
KubernetesJob
here
a
I've got the annotation by adding it like this to the json template:
Copy code
"metadata": {
            "labels": {
              "app": "prefect-DNR"
            },
            "annotations": {
              "<http://cluster-autoscaler.kubernetes.io/safe-to-evict|cluster-autoscaler.kubernetes.io/safe-to-evict>": "false"
            }
          }
it worked because I can see it when i describe the job
🙌 1