SpringCloudNetflixSidecar

1. 개요

Spring Cloud Netflix Sidecar 란?

A Sidecar as referred to in Polyglot support with Sidecar is a Spring Boot application that acts as a bridge between your service infrastructure and a service that is not written in a JVM language. Apps written in Python, Go, Ruby, C#, NodeJS, Erlang or really any other language that can bind something to a port come to mind.

  • Non-JVM 어플리케이션을 Spring Cloud(Zuul, Eureka, Spring Cloud Config ...)에 쉽게 편입 시키는 기능을 지원한다.

사용하는 이유

  1. service discovery : host:port/ 를 통하여 다른 방법에 비해 편하게 Non-JVM 어플리케이션에서 다른 Eureka 클라이언트를 찾을 수 있다.

  2. monitoring : health check uri 설정을 통해 Eureka서버에서 Non-JVM 어플리케이션의 동작 여부를 알수 있다.

  3. routing / proxying : Zuul을 통하여 Request를 받을 수 있다.

  4. balancing : 내장된 Ribbon을 통해 Client side load balancing 기능을 지원 한다.

  5. counfiguration : Spring Cloud Config를 통하여 configuration properties를 받을 수 있다.

2. 구성방법

설치방법

  1. Spring boot 프로젝트 생성

  2. pom.xml에 dependency 추가

  3. @EnableSidecar 어노테이션 추가

  4. bootstrap.yml 파일에 설정 추가

3. 동작

  1. discovery sidecar application

    • Eureka에 등록된 serviceId(NODE-SERVICE)로 사용 가능

      discovery-node-server

    • 내부 서비스에서 node sever를 접근하는 예제 코드

      discovery-sample-code

  2. discovery another application

    • sidecarHostName : sidecarPort / servceId

    • serviceId를 이용하여 Node Server에서 다른 micro service 사용 가능

    • Node server에서 http://localhost:8009/Service1/someEndPointarrow-up-right 를 접근하는 경우 sidecar application이 Eureka서버에서 서버 정보를 가져와 Service1으로 라우팅 해준다.

      discovery-another-service

Last updated