Skip to content

This project contains samples demonstrating the usage of side car polygot

Notifications You must be signed in to change notification settings

BarathArivazhagan/spring-cloud-sidecar-polygot

Repository files navigation

spring-cloud-sidecar-polygot-demo

This project demonstrates the usage of netflix`s side car polygot. Spring cloud side car helps to register non jvm applications in eureka service registration server and available as part of service discovery to route traffic to non jvm applications through sidecar proxy.

Note: Branches 1.x.x/2.x.x versions makes it compatible with spring boot versions 1.x.x/2.x.x. Kindly choose branch as per spring boot release versions.

side car

Compatability Matrix

choose the branch based on below versions.

Branch/Version Spring Boot Spring Cloud Node Js
master 2.3.0.RELEASE Hoxton.SR5 14.4.0
2.2.2 2.2.2.RELEASE Hoxton.RELEASE 12.4.0
2.1.5 2.1.5.RELEASE Greenwich.SR1 12.4.0
2.1.4 2.1.4.RELEASE Greenwich.RELEASE 12.4.0
2.1.2 2.1.2.RELEASE Greenwich.RC2 10.16.0
2.0.3 2.0.3.RELEASE Finchley.RELEASE 8.16.0
1.5.6 1.5.6.RELEASE Dalston.SR3 8.16.0

Projects

Name Port Description
eureka-server 9000 Eureka server - service registration server
csstore-microservice 9001 Service discovery microservice registered with eureka server
msstore-microservice 9002 Service discovery microservice registered with eureka server
sidecar 9004 Side car proxy for routing and filtering to wstore node app
wstore-node-express 3000 Node express (non jvm ) application
zuul-proxy 9005 Zuul proxy for routing and filtering

How to build and run ?

  • Download/Clone the repository :
$ git clone https://github.com/BarathArivazhagan/spring-cloud-sidecar-polygot.git
$ cd spring-cloud-sidecar-polygot
  • Maven build :
 $ ./mvnw clean install
  • Docker image build :

    # Note change the docker images as per your image name in docker compose file
    $ docker-compose build 
  • To run the application :

$ docker-compose up

How to test the application ?

Use zuul proxy to route to respective microservices.

zuul route definition :

zuul:
  routes:
    msstore :       
        path: /msstore/**
        url: http://localhost:9002
    csstore: 
        path: /csstore/**
        url: http://localhost:9001

Service Urls:

http://localhost:9005/msstoremsstore
http://localhost:9005/csstorecsstore
http://localhost:9005/csstorewstore

Side car route definition

zuul:
  routes:
    wstore: 
      path: /wstore/**
      url: http://localhost:3000

sidecar:
  port: 3000
  health-uri: http://localhost:3000/health

Notes :

sidecar.port : Port must be same as the non jvm port
sidecar.health-uri: non jvm application should expose this url with json message {"STATUS" : "UP"} to indicate sidecar the app is UP.

How to test sidecar ?

Navigate to http://localhost:9004/wstore/home --> sidecar routes to non jvm(nodejs app)

Why Zuul as well as side car ?

yes, thats right. @EnableSideCar includes @EnableZuulProxy,so side car can act as zuul proxy itself. In order to provide separate proxy for side car(non jvm) based applications, this repo contains two proxies

zuul-proxy : provides proxy to jvm based applications.
sidecar : provides proxy to non jvm based applications.

How to rebuild the project after the changes?

$ docker-compose build

References