ServiceEntry: Promote configured WE annotations into workload labels #14198
Promoted annotation keys can overwrite an existing label with the same key (from metadata or spec). That can unintentionally change selection/metadata behavior, and it contradicts the motivation of avoiding label collisions. Consider only promoting when the key is not already present in the merged label set (or explicitly document that promotion overrides labels).
This option comment says promotion is for endpoint plugins, but the promoted keys are merged into AugmentedLabels which are also consumed by core logic (e.g. transport socket match metadata for Istio auto-mTLS). Please clarify the potential side-effects/collision risks so callers choose safe keys.
Pull request overview
This PR adds an opt-in mechanism to copy a configured subset of WorkloadEntry metadata annotations into the derived workload’s AugmentedLabels, enabling endpoint plugins to observe those values while avoiding wholesale annotation propagation.
Changes:
Options.PromoteWorkloadEntryAnnotations to configure which annotation keys to promote.WorkloadEntry → selectedWorkload conversion.Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
| ---- | ----------- |
| pkg/kgateway/extensions2/plugins/serviceentry/promote_annotations_test.go | Adds tests validating configured annotation promotion into AugmentedLabels. |
| pkg/kgateway/extensions2/plugins/serviceentry/plugin.go | Adds the new Options.PromoteWorkloadEntryAnnotations option and documents intended behavior. |
| pkg/kgateway/extensions2/plugins/serviceentry/endpoints.go | Updates inline endpoint conversion calls to the expanded selectedWorkloadFromEntry signature. |
| pkg/kgateway/extensions2/plugins/serviceentry/collections.go | Wires the option through collections and performs the actual annotation-to-label promotion. |
It basically the responsibility of the plugin developer.
Might also be the intention of the plugin to overwrite the label with a promoted annotation.
Approved these changes.
davidjumani
ymesika
<!--
Thanks for opening a PR! Please delete any sections that don’t apply.
-->
Description
<!--
A concise explanation of the change. You may include:
Fixes #123-->
Add
Options.PromoteWorkloadEntryAnnotationsso callers can supply a set of WorkloadEntry annotation keys to copy verbatim into AugmentedLabels, letting endpoint plugins observe them.kgateway stays agnostic to the keys' meaning.
Main reason not to include all annotations instead of configured ones:
1. Annotation values aren't valid label values
2. Collisions with meaningful labels
3. Endpoint hash stability
Change Type
<!--
Select one or more of the following by including the corresponding slash-command:
-->
/kind cleanup
Changelog
<!--
Provide the exact line to appear in release notes for the chosen changelog type.
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
-->
``
release-note
``NONE
(not a user facing change)
Additional Notes
<!--
Any extra context or edge cases for reviewers.
-->