<#6421 Feat: Apply labels and annotations set via ...
# flyte-github
c
#6421 Feat: Apply labels and annotations set via task decorator to pods and CR objects Pull request opened by fg91 ## Tracking issue Closes #6238 ## Why are the changes needed? Today, as a Flyte user, I have the following options to set labels/annotations on the pods/CRD objects of K8s tasks in a flyte workflow execution: 1. Set via pod template: def task( pod_template=PodTemplate(annotations=..., labels=...) ) This sets labels/annotations on the pods of individual tasks. For distributed tasks (like pytorch, ray, ...) this sets the metadata not on the CRD object but its pod template spec. 2. Set via
pyflyte run --labels ... --annotations ...
This applies the metadata to all K8s objects in a flyte workflow execution, including task pods and task CRD objects. However, this mechanism doesn't work on an individual task level. ## What changes were proposed in this pull request? As a Flyte user, I would like to be able to specify specific labels/annotations for individual k8s task CRD objects like pytorch jobs, ray job, ... (the same way I already can today for pods via the pod template). For this aim, the following arguments are added to the task decorator: @task( labels=..., annotations=..., ) def test_task(): ... These labels and annotations are added to the object metadata of the object executing the task (Pod or CRD object). This PR adds a
metadata
field of type
K8sObjectMetadata
to the
TaskMetadata
proto message and applies this additional metadata in the plugin manager's
addObjectMetadata
function. ## How was this patch tested? • Executed flyteadmin and flytpropeller with these changes and the corresponding changes in flytekit. • Adapted unit tests • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. ## Related PRs flyteorg/flytekit#3243 ### Summary by Bito This pull request adds a new metadata field to the TaskMetadata proto, enabling users to apply custom labels and annotations to Kubernetes objects. The enhancement spans multiple language implementations including Go, TypeScript, Python, and Rust, providing more granular control over metadata for both pods and custom resources. Unit tests added: False Estimated effort to review (1-5, lower is better): 5 flyteorg/flyte