Add label selector support to exportTo field#35
Draft
Conversation
Phase 2: Core Model Changes - Added ExportToTarget struct in pilot/pkg/model/exportto.go - ParseExportTo function to convert API types to internal types - LabelSelectorAsSelector for converting label selectors Phase 3: ExportToFilter component - Added exportto_filter.go in pkg/kube/namespace - Watches namespace changes and caches labels for selector evaluation - Provides MatchesSelector method for visibility checking Phase 4: Validation changes - Updated validateExportTo to handle exportToSelectors field - Added validateExportToSelectors for label selector validation - Validates operator types and expression values Updated all references to use typev1beta1.LabelSelector to match the refactored API types. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Phase 5-7: Integration Changes - Updated push_context.go to use ParseExportTo() for VirtualService and DestinationRule - Updated ServiceEntry conversion to parse exportToSelectors field - Added support for exportTo annotation parsing in Kubernetes Service conversion - Implemented KubeNamespaceLabelsGetter for namespace label lookup - Wired up NamespaceLabelsGetter in bootstrap/server.go Test Updates: - Added comprehensive ExportToTarget unit tests (exportto_test.go) - Added KubeNamespaceLabelsGetter tests (namespace_labels_test.go) - Updated all test files to use typev1beta1.LabelSelector for MeshConfig - Fixed TestServiceConversionWithExportToAnnotation for empty annotation handling Files Added: - pilot/pkg/model/exportto_test.go (394 lines) - pilot/pkg/serviceregistry/kube/controller/namespace_labels.go (51 lines) - pilot/pkg/serviceregistry/kube/controller/namespace_labels_test.go (127 lines) Files Modified: - pilot/pkg/model/push_context.go: VirtualService and DestinationRule use ParseExportTo - pilot/pkg/serviceregistry/serviceentry/conversion.go: Parse exportToSelectors - pilot/pkg/serviceregistry/kube/conversion.go: Handle exportTo annotation - pilot/pkg/bootstrap/server.go: Wire up NamespaceLabelsGetter - Multiple test files updated for type compatibility Related to istio#50661 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…LabelSelector MeshConfig fields (DiscoverySelectors, ServiceScopeConfigs) should use the mesh.v1alpha1.LabelSelector type defined locally in config.proto, not type.v1beta1.LabelSelector which is for networking API fields. This aligns with the istio-api changes where config.pb.go was reverted to keep LabelSelector types in the mesh/v1alpha1 package. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…ields The LabelSelectorAsSelector helper functions in services.go and filter.go need to use meshapi.LabelSelector (v1alpha1) not typev1beta1.LabelSelector because they process MeshConfig.DiscoverySelectors and MeshConfig.ServiceScopeConfigs which use the local mesh API LabelSelector type. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Use kclient.New[*corev1.Namespace](client) instead of client.Kube().CoreV1().Namespaces() to create the namespace client that implements kclient.Client[*corev1.Namespace]. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
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.
Summary
Implements GitHub issue istio#50661 - Add label selector support to the
exportTofield for VirtualService, DestinationRule, and ServiceEntry resources.This allows services and configuration to be dynamically exported to namespaces matching label selectors, without requiring explicit namespace names.
Changes
API Changes (istio-api repo)
export_to_selectorsfield to VirtualService, DestinationRule, and ServiceEntryLabelSelectortype intype/v1beta1for networking resourcesLabelSelectorinmesh/v1alpha1Implementation (this repo)
pilot/pkg/model/exportto.go): Combines static namespaces with label selectorsvalidateExportToSelectors()for label selector validationExample Usage
Test Plan
Related
🤖 Generated with Claude Code