2020년 6월 27일 토요일

Spring Cloud Zuul

스프링부트 클라우드 + 넥플릭스 덕분에 마이크로서비스 구축이 이렇게나 재밌을수가..

Spring Cloud Zuul
일단 API GATEWAY로서 라우팅, 엔드포인트제공, 필터링, 로깅-모니터링은 기본이고 인증, 로드밸런싱, 장애대응 까지 소프트웨어적으로 가능하게 만들어 두었다니, 사랑해요 넥플릭스 개발자들.

일단 가장 쓰기편한 조합은 Eureka 와 연동하는것. Zuul 에는 Hystrix(Circuit Breaker), Ribbon(Load Balancer-round robin type) 이 탑재되어 있다.

1.Spring Cloud Zuul 설정
부트초기화 사이트에서 zuul 하고 eureka client 추가해서 프로젝트 생성.

- application.yml 생성
server:
port: 8100 <- 암거나

spring:
application:
name: ${NAME:zuul} <- 유레카 서버에서 확인할 이름
zuul:
routes:
service-1:
path: /ping
serviceId: customerservice <- 이거는 유레카 클라이언트의 이름과 동일해야 유레카가 해당이름의 서버를 찾아 준다.
service-2:
path: /fuckapple
serviceId: customerservice2 <- 뻑은 다른서버

eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: ${EUREKA_URL:http://127.0.0.1:8761/eureka/}, http://192.168.0.103:8671/eureka/
추가로 hystrix, ribon 설정을 서비스 별로 지정할수 있다.
hystrix : https://blog.naver.com/sharplee7/221503517533 <- 상세히 잘되어있음
ribon : https://blog.naver.com/sharplee7/221505552280 <- 상세히 잘되어있음

참고 떙큐

0 comments:

댓글 쓰기