Skip to content

Conversation

@prashanthjos
Copy link
Contributor

@prashanthjos prashanthjos commented Nov 30, 2025

Add Label Selector Support for VirtualService Gateway Selection

Overview

This PR introduces a new gateway_selector field to the VirtualService API that enables selecting gateways using Kubernetes-style label selectors instead of explicit gateway names.

Problem

Currently, VirtualServices require explicitly listing gateway names, which creates operational challenges when updating or replacing gateways across hundreds of VirtualServices.

Related Issue

Fixes: #58426

Solution

Add a new gateway_selector field with Kubernetes-style label selectors.

API Changes

New Message

message GatewayReference {
  string name = 1;
  map<string, string> selector = 2;
}

Updated VirtualService

message VirtualService {
  repeated string hosts = 1;
  repeated string gateways = 2;
  repeated GatewayReference gateway_selector = 7;  // NEW
  repeated HTTPRoute http = 3;
  // ...
}

Examples

Select by labels

gateway_selector:
- selector:
    env: prod
    version: v1

Mix names and selectors

gateway_selector:
- name: "mesh"
- selector:
    env: prod

Benefits

  • Update gateways without modifying VirtualServices
  • Enable blue-green deployments via relabeling
  • Support multi-environment routing
  • Reduce configuration drift

Backward Compatibility

  • Existing gateways field unchanged
  • No breaking changes
  • gateway_selector takes precedence if both specified

Files Changed

  • networking/v1alpha3/virtual_service.proto
  • Generated Go code and CRDs

Related Work

Requires implementation PR in istio/istio repository.

…selection

This commit introduces a new `gateway_selector` field to the VirtualService API that allows selecting gateways using label selectors instead of explicit
names, following the Kubernetes Service selector pattern.

Changes:
- Add GatewayReference message with name and selector fields
- Add gateway_selector field to VirtualService (field number 7)
- Update documentation with examples and usage patterns
- Mark gateways and gateway_selector as mutually exclusive
- Generate corresponding Go code and CRD definitions

The new field enables dynamic gateway selection, reducing operational overhead when updating or replacing gateways across multiple VirtualServices.

Fixes: #58426
@prashanthjos prashanthjos requested a review from a team as a code owner November 30, 2025 03:21
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 30, 2025
@istio-testing
Copy link
Collaborator

Hi @prashanthjos. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@istio-policy-bot
Copy link

🤔 🐛 You appear to be fixing a bug in Go code, yet your PR doesn't include updates to any test files. Did you forget to add a test?

Courtesy of your friendly test nag.

@keithmattix keithmattix added the do-not-merge/hold Block automatic merging of a PR. label Nov 30, 2025
@prashanthjos
Copy link
Contributor Author

@keithmattix, could you please let me know if there’s a specific reason the PR is labeled as do-not-merge/hold?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants