@@ -1409,7 +1409,7 @@ func (t *Translator) processDestination(name string, backendRefContext BackendRe
14091409 ds = t .processServiceDestinationSetting (name , backendRef .BackendObjectReference , backendNamespace , protocol , resources , envoyProxy )
14101410 svc := resources .GetService (backendNamespace , string (backendRef .Name ))
14111411 ds .IPFamily = getServiceIPFamily (svc )
1412- ds .ZoneAwareRoutingEnabled = isZoneAwareRoutingEnabled (svc )
1412+ ds .ZoneAwareRouting = processZoneAwareRouting (svc )
14131413
14141414 case egv1a1 .KindBackend :
14151415 ds = t .processBackendDestinationSetting (name , backendRef .BackendObjectReference , backendNamespace , protocol , resources )
@@ -1571,12 +1571,12 @@ func (t *Translator) processServiceDestinationSetting(
15711571 }
15721572
15731573 return & ir.DestinationSetting {
1574- Name : name ,
1575- Protocol : protocol ,
1576- Endpoints : endpoints ,
1577- AddressType : addrType ,
1578- ZoneAwareRoutingEnabled : isZoneAwareRoutingEnabled (service ),
1579- Metadata : buildResourceMetadata (service , ptr .To (gwapiv1 .SectionName (strconv .Itoa (int (* backendRef .Port ))))),
1574+ Name : name ,
1575+ Protocol : protocol ,
1576+ Endpoints : endpoints ,
1577+ AddressType : addrType ,
1578+ ZoneAwareRouting : processZoneAwareRouting (service ),
1579+ Metadata : buildResourceMetadata (service , ptr .To (gwapiv1 .SectionName (strconv .Itoa (int (* backendRef .Port ))))),
15801580 }
15811581}
15821582
@@ -1596,24 +1596,28 @@ func getBackendFilters(routeType gwapiv1.Kind, backendRefContext BackendRefConte
15961596 return nil
15971597}
15981598
1599- func isZoneAwareRoutingEnabled (svc * corev1.Service ) bool {
1599+ func processZoneAwareRouting (svc * corev1.Service ) * ir. ZoneAwareRouting {
16001600 if svc == nil {
1601- return false
1601+ return nil
16021602 }
16031603
16041604 if trafficDist := svc .Spec .TrafficDistribution ; trafficDist != nil {
1605- return * trafficDist == corev1 .ServiceTrafficDistributionPreferClose
1605+ return & ir.ZoneAwareRouting {
1606+ MinSize : 1 ,
1607+ }
16061608 }
16071609
16081610 // Allows annotation values that align with Kubernetes defaults.
16091611 // Ref:
16101612 // https://kubernetes.io/docs/concepts/services-networking/topology-aware-routing/#enabling-topology-aware-routing
16111613 // https://github.com/kubernetes/kubernetes/blob/9d9e1afdf78bce0a517cc22557457f942040ca19/staging/src/k8s.io/endpointslice/utils.go#L355-L368
1612- if val , ok := svc .Annotations [corev1 .AnnotationTopologyMode ]; ok {
1613- return val == "Auto" || val == "auto"
1614+ if val , ok := svc .Annotations [corev1 .AnnotationTopologyMode ]; ok && val == "Auto" || val == "auto" {
1615+ return & ir.ZoneAwareRouting {
1616+ MinSize : 3 ,
1617+ }
16141618 }
16151619
1616- return false
1620+ return nil
16171621}
16181622
16191623func (t * Translator ) processDestinationFilters (routeType gwapiv1.Kind , backendRefContext BackendRefContext , parentRef * RouteParentContext , route RouteContext , resources * resource.Resources ) (* ir.DestinationFilters , error ) {
0 commit comments