Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ambient: implement service.trafficDistribution field in Service #50519

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions pilot/pkg/serviceregistry/kube/controller/ambient/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ func (a *index) constructService(svc *v1.Service, w *Waypoint) *workloadapi.Serv
}

var lb *workloadapi.LoadBalancing
if svc.Spec.TrafficDistribution != nil && *svc.Spec.TrafficDistribution == v1.ServiceTrafficDistributionPreferClose {
lb = &workloadapi.LoadBalancing{
// Prefer endpoints in close zones, but allow spilling over to further endpoints where required.
RoutingPreference: []workloadapi.LoadBalancing_Scope{
workloadapi.LoadBalancing_NETWORK,
workloadapi.LoadBalancing_REGION,
workloadapi.LoadBalancing_ZONE,
workloadapi.LoadBalancing_SUBZONE,
},
Mode: workloadapi.LoadBalancing_FAILOVER,
}
}
if svc.Labels[constants.ManagedGatewayLabel] == constants.ManagedGatewayMeshControllerLabel {
// This is waypoint. Enable locality routing
lb = &workloadapi.LoadBalancing{
Expand Down