Support DNS based Service Discovery

Adds new two DiscoveryClient implementations that depend on native Service Discovery supported by Cloud Foundry.

CloudFoundryAppServiceDiscoveryClient uses cf-java-client and find container's index-based route (e.g. 0.billing.apps.internal, 1.billing.apps.internal, 2.billing.apps.internal).
SimpleDnsBasedDiscoveryClient simply uses DNS and resolve container's ip (e.g. 10.250.56.12, 10.254.160.118, 10.254.112.192). does not depend on cf-java-client
By default, existing CloudFoundryDiscoveryClient is chosen.
Configuring spring.cloud.cloudfoundry.discovery.use-dns=true enables CloudFoundryAppServiceDiscoveryClient.
Configuring spring.cloud.cloudfoundry.discovery.use-dns=true and spring.cloud.cloudfoundry.discovery.use-container-ip=true enables SimpleDnsBasedDiscoveryClient.

This DiscoveryClient eliminates the limitation of Turbine on Cloud Foundry and does not need Turbine Stream.

In some environments (such as in a PaaS setting), the classic Turbine model of pulling metrics from all the distributed Hystrix commands does not work.

See gh-19
This commit is contained in:
Toshiaki Maki
2018-04-18 03:34:43 +09:00
committed by Spencer Gibb
parent a64ebf099a
commit f0ef4f08bf
8 changed files with 426 additions and 9 deletions

View File

@@ -22,7 +22,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.cloudfoundry.discovery.CloudFoundryDiscoveryClient;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.cloudfoundry.discovery.EnableCloudFoundryClient;
import org.springframework.context.annotation.Bean;
@@ -55,7 +55,7 @@ public class CloudFoundryApplication {
}
@Bean
CommandLineRunner demo(CloudFoundryDiscoveryClient discoveryClient) {
CommandLineRunner demo(DiscoveryClient discoveryClient) {
Log log = LogFactory.getLog(getClass());
return args -> discoveryClient.getServices().forEach(svc -> {
log.info("service = " + svc);