[2.3.x Backport] feat(Istio): Add label selector exclusions for ServiceEntries (#14328)#14359
Merged
Merged
Conversation
…ay-dev#14328) Signed-off-by: Yossi Mesika <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Backports #14328 to the v2.3.x line by adding a controller/Helm-configurable mechanism to exclude specific Istio ServiceEntry objects from kgateway’s ServiceEntry-backed backend and endpoint discovery using standard Kubernetes label selectors.
Changes:
- Add a new settings/env var + Helm value (
serviceEntriesExclusionLabelSelectors/KGW_SERVICE_ENTRIES_EXCLUSION_LABEL_SELECTORS) and propagate it into the controller deployment. - Centralize JSON label selector parsing/validation helpers and reuse them for discovery namespace selectors and ServiceEntry exclusions.
- Filter the ServiceEntry KRT collection used by the ServiceEntry plugin, with unit tests covering parsing and exclusion behavior.
Reviewed changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| api/settings/settings.go | Adds the ServiceEntriesExclusionLabelSelectors setting (JSON-encoded selector list) with a default of []. |
| api/settings/settings_test.go | Extends settings tests to include the new env var and default expectations. |
| install/helm/kgateway/templates/deployment.yaml | Wires Helm values into the controller via KGW_SERVICE_ENTRIES_EXCLUSION_LABEL_SELECTORS. |
| install/helm/kgateway/values.yaml | Documents and introduces serviceEntriesExclusionLabelSelectors Helm value. |
| pkg/pluginsdk/collections/label_selectors.go | Introduces reusable parsing/validation helpers for JSON label selector lists, plus match helper. |
| pkg/pluginsdk/collections/label_selectors_test.go | Adds unit tests for selector parsing defaults, invalid operators, and exclusion-empty-selector rejection. |
| pkg/pluginsdk/collections/discovery.go | Refactors discovery namespace selector parsing to reuse the new selector parsing helper. |
| pkg/pluginsdk/collections/collections.go | Parses/validates the ServiceEntry exclusion selectors once and stores them on CommonCollections. |
| pkg/kgateway/extensions2/plugins/serviceentry/plugin.go | Plumbs selector defaults from CommonCollections into plugin options, with a test-oriented fallback parse. |
| pkg/kgateway/extensions2/plugins/serviceentry/collections.go | Filters the ServiceEntry input collection used for backend/endpoint discovery based on exclusion selectors. |
| pkg/kgateway/extensions2/plugins/serviceentry/exclusion_test.go | Adds tests validating selector-based ServiceEntry exclusion and the filtered backend collection behavior. |
| test/helm/testdata/kgateway/additional-labels.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/controller-empty-pod-annotations.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/controller-empty-tolerations-override.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/controller-empty-topology-spread-constraints-override.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/controller-null-pod-annotations.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/controller-null-tolerations-fallback.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/controller-null-topology-spread-constraints-fallback.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/controller-overrides-replace-not-merge.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/controller-overrides-top-level-values.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/default.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/hpa-and-vpa.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/pdb-max-unavailable.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/pdb-min-available.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/priority-class-name.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/probes-full-override.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/prometheus-annotations-disabled.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/readiness-probe-override.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/replicas-null.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/replicas-zero.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/service-full-config.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/service-monitor-enabled.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/startup-probe-override.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/tolerations.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/topology-spread-constraints.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/xds-tls-enabled-extraenv-dedup.golden | Updates rendered deployment env list to include the new selector env var default []. |
| test/helm/testdata/kgateway/xds-tls-enabled.golden | Updates rendered deployment env list to include the new selector env var default []. |
davidjumani
approved these changes
Jul 7, 2026
ymesika
enabled auto-merge
July 8, 2026 07:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Backport of #14328 to v2.3.x.
Change Type
/kind feature
Changelog
Additional Notes