Skip to content

Commit

Permalink
ambient: implement service.trafficDistribution field in Service (#50519)
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjohn committed May 8, 2024
1 parent 9f7a691 commit f002428
Showing 1 changed file with 12 additions and 0 deletions.
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 @@ -147,6 +147,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

0 comments on commit f002428

Please sign in to comment.