@@ -92,31 +92,40 @@ func (d *adcClient) getConfigsForGatewayProxy(tctx *provider.TranslateContext, g
9292 if ! ok {
9393 return nil , fmt .Errorf ("no service found for service reference: %s" , namespacedName )
9494 }
95- endpoint := tctx .EndpointSlices [namespacedName ]
96- if endpoint == nil {
97- return nil , nil
98- }
99- upstreamNodes , err := d .translator .TranslateBackendRefWithFilter (tctx , gatewayv1.BackendRef {
100- BackendObjectReference : gatewayv1.BackendObjectReference {
101- Name : gatewayv1 .ObjectName (provider .ControlPlane .Service .Name ),
102- Namespace : (* gatewayv1 .Namespace )(& gatewayProxy .Namespace ),
103- Port : ptr .To (gatewayv1 .PortNumber (provider .ControlPlane .Service .Port )),
104- },
105- }, func (endpoint * discoveryv1.Endpoint ) bool {
106- if endpoint .Conditions .Terminating != nil && * endpoint .Conditions .Terminating {
107- log .Debugw ("skip terminating endpoint" , zap .Any ("endpoint" , endpoint ))
108- return false
95+
96+ // APISIXStandalone, configurations need to be sent to each data plane instance;
97+ // In other cases, the service is directly accessed as the adc backend server address.
98+ if d .BackendMode == BackendModeAPISIXStandalone {
99+ endpoint := tctx .EndpointSlices [namespacedName ]
100+ if endpoint == nil {
101+ return nil , nil
102+ }
103+ upstreamNodes , err := d .translator .TranslateBackendRefWithFilter (tctx , gatewayv1.BackendRef {
104+ BackendObjectReference : gatewayv1.BackendObjectReference {
105+ Name : gatewayv1 .ObjectName (provider .ControlPlane .Service .Name ),
106+ Namespace : (* gatewayv1 .Namespace )(& gatewayProxy .Namespace ),
107+ Port : ptr .To (gatewayv1 .PortNumber (provider .ControlPlane .Service .Port )),
108+ },
109+ }, func (endpoint * discoveryv1.Endpoint ) bool {
110+ if endpoint .Conditions .Terminating != nil && * endpoint .Conditions .Terminating {
111+ log .Debugw ("skip terminating endpoint" , zap .Any ("endpoint" , endpoint ))
112+ return false
113+ }
114+ return true
115+ })
116+ if err != nil {
117+ return nil , err
118+ }
119+ for _ , node := range upstreamNodes {
120+ config .ServerAddrs = append (config .ServerAddrs , "http://" + net .JoinHostPort (node .Host , strconv .Itoa (node .Port )))
121+ }
122+ } else {
123+ config .ServerAddrs = []string {
124+ fmt .Sprintf ("http://%s.%s:%d" , provider .ControlPlane .Service .Name , gatewayProxy .Namespace , provider .ControlPlane .Service .Port ),
109125 }
110- return true
111- })
112- if err != nil {
113- return nil , err
114- }
115- for _ , node := range upstreamNodes {
116- config .ServerAddrs = append (config .ServerAddrs , "http://" + net .JoinHostPort (node .Host , strconv .Itoa (node .Port )))
117126 }
118127
119- log .Debugf ("add server address to config.ServiceAddrs: %v" , config .ServerAddrs )
128+ log .Debugw ("add server address to config.ServiceAddrs" , zap . Strings ( "config.ServerAddrs" , config .ServerAddrs ) )
120129 }
121130
122131 return & config , nil
0 commit comments