0

I have an application in python using port 8004, which has end-points. I need to integrate it into microservices platform, which has Eureka discovery server port 8001, Spring Boot Admin port 8002, gateway port 80. Gateway uses Zuul proxy, and it forwards requests to required services.

I have two options:

  1. Change the code of my python-app, so it can have endpoints for Spring Cloud services
  2. Or use Spring Cloud Sidecar - which has these endpoints implemented. https://cloud.spring.io/spring-cloud-netflix/multi/multi__polyglot_support_with_sidecar.html

I decided to have sidecar. Sidecar port 8003, python-app port 8004. @EnableSidecar annotation + @EnableDiscoveryClient - and magic. Then I need to add gateway configuration to forward requests to python-service. And I need configuration for sidecar Zuul Proxy, so it forwards requests to the python application.

gateway port 80 -> sidecar port 8003 -> python-app port 8004.

Beautiful, and it works. When I open Eureka web-ui, all services are there. When I open Spring Boot Admin UI, it says that python-service (its sidecar) is down.

Spring Boot Admin client (configuration on the sidecar side), its port is 28003, thus that is different from sidecar.

management:
  server:
    port: 18003
  endpoints:
    web:
      exposure:
        include: '*'
  endpoint:
    health:
      show-details: ALWAYS

I replaced @EnableSidecar with @EnableZuulProxy. Now everything works, and python-app is visible in Spring Boot Admin.

My two questions:

  1. Why does @EnableSidecar has @EnableCircuitBreaker if sidecar does not need circuit breaker by default? It makes sense if there is one instance of sidecar and multiple instances of python-service. I have 1:1 - one sidecar and one python-app. If python app is not available, sidecar should return an error. I do not need the circuit breaker? Or do I?

  2. Why annotation @EnableSidecar affects Spring Boot client, so it is not displayed on Spring Boot Admin UI. I think there is a bug or how do I enable sidecar to be monitored in Spring Boot Admin web-ui.

Spring Boot version is 2.0.7, Spring Cloud version is 2.0.0

Yan Khonski
  • 12,225
  • 15
  • 76
  • 114

2 Answers2

0

The sidecar should not proxy requests into the non-jvm service. It uses the java eureka client to register on behalf of the non-jvm service. The non-jvm service can then use the embedded zuul in the sidecar to make requests to other services. It does not need to know about eureka, hystrix (circuit-breaker) or ribbon (client side loadbalancer), but this is optional.

spencergibb
  • 24,471
  • 6
  • 69
  • 75
  • Agree with that if the application under sidecar needs to access other services in the platform. However, what if user makes a request, and **gateway forwards it to the application VIA the sidecar**? – Yan Khonski Apr 30 '19 at 16:41
  • It wasn't built to do that – spencergibb Apr 30 '19 at 21:43
0

Well, I resolved this issue by upgrading Spring Cloud into 2.1.1-RELEASE. Then I had another problem.

Field restTemplate in org.springframework.cloud.netflix.sidecar.LocalApplicationHealthIndicator required a single bean, but 3 were found

To fix it, I added configuration

@Configuration
public class RestTemplateConfig {

    @Primary
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}

From logical point of view, sidecar should forward requests to the application. With Hystrix, it will not wait for timely response, but rather fail quicker. What are other reasons to have circuit-breaker pattern and functionality in sidecar?

Yan Khonski
  • 12,225
  • 15
  • 76
  • 114