Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring-cloud-loabalancer configuring static server list

We're moving away from the spring-cloud Netflix OSS ecosystem one step at a time. Currently we're implementing spring-cloud-loadbalancer and removing Ribbon. However we used to have a lot of static services in our integration tests, now with the move from ribbon towards spring-cloud-loadbalancer those properties are not being picked up any longer. i.e.:

foo-service.ribbon.NIWSServerListClassName=com.netflix.loadbalancer.ConfigurationBasedServerList
foo-service.ribbon.listOfServers=localhost:9876

We've migrated towards using spring-cloud-loadbalancer in the following way
First we annotated our Webclient.Builder with @LoadBalanced like this

@Bean
@LoadBalanced
fun webClientBuilder() = WebClient.builder()

And then we've added the @LoadBalancerClient annotation on the client classes like this

@LoadBalancerClient(name = "foo-service", configuration = [FooServiceConfiguration::class])
class FooServiceClient(private val basicAuthWebClient: WebClient)

This results in our tests failing with an UnknownHostException for foo-service.

Now My question is how do we configure this static server list in the new spring-cloud-loadbalancer?

like image 783
J.Pip Avatar asked Oct 15 '22 07:10

J.Pip


1 Answers

Based on @spencergibb's comment, I guess something like this should work:

spring:
  cloud:
    discovery:
      client:
        simple:
          instances:
            foo-service:
              - instanceId: foo1
                serviceId: foo-service
                host: localhost
                port: 9876```
like image 66
Mihaita Tinta Avatar answered Oct 21 '22 08:10

Mihaita Tinta