Serhii
02/28/2024, 3:08 PMfrom prefect.infrastructure.kubernetes import KubernetesJob
job = KubernetesJob()
job.customizations = jsonpatch.JsonPatch([
{
'op': 'add',
'path': '/spec/template/metadata/labels',
'value': {
'<http://app.kubernetes.io/instance|app.kubernetes.io/instance>': 'prefect-agent'
}
}
])
...
But all I got was:
jsonpointer.JsonPointerException: member 'metadata' not found in {'spec': {'containers': [{'env': [{'name': .....
Marvin
02/28/2024, 3:09 PMKubernetesJob
job template can be challenging. There's not a clear solution provided in the official resources or in the issues mentioned.
It's important to note that Kubernetes expects metadata
to already exist when you apply a JSON patch to add labels. As for your error, "member 'metadata' not found"
, it indicates that the JSON patch operation expected to find the metadata
key in the base structure but didn't.
One potential solution could be ensuring that you're patching an existing metadata
block rather than attempting to add it where it doesn't exist. You may need to review the base Kubernetes Job definition used by Prefect to ensure it has a metadata
section you can modify.
Given the specifics of the issue, it may also be beneficial to explicitly request help from the Prefect community or report this issue on GitHub if you continue to encounter problems.
For more in-depth assistance, consider reaching out:
- Directly in the Prefect Slack community: Prefect Slack
- Prefect GitHub Issues for potential bugs: Prefect GitHub
Relevant Prefect documentation and issue links:
- Developing a new worker type
- Infrastructure Overview
- Related GitHub Issue about labels not being applied in Kubernetes: Issue #11172
- GitHub Issue about adding annotations, similar to labels: Issue #8281Serhii
02/29/2024, 9:38 AMfrom prefect.infrastructure.kubernetes import KubernetesJob
job = KubernetesJob()
Is there a way to add /spec/template/metadata path in order to modify it in future?