Example for Spring cloud (netflix OSS, spring cloud)
์ด ํ๋ก์ ํธ๋ ์๋์ ๊ฐ์ ์์๋ฅผ ํฌํจํ๊ณ ์์ต๋๋ค
- eureka-server (๋์ค์ปค๋ฒ๋ฆฌ ์๋น์ค)
- 3๊ฐ์ peer-to-peer ๋์ค์ปค๋ฒ๋ฆฌ ์๋ฒ
- ๊ฐ ์๋ฒ๋ -Dspring.profiles.active=peer1 or peer2 or peer3 ์ต์ ์ ํตํด ๊ตฌ๋ํ์ฌ์ผ ํฉ๋๋ค.
- ์ฌ์ฉํ๋ ํฌํธ๋ 8800-8802 ์ ๋๋ค. ๊ฐ ์๋ฒ๋ ์ํ๋ฅผ ํ์ธํ ์ ์๋ ๋์๋ณด๋๋ฅผ ํฌํจํฉ๋๋ค.
- eureka-client (๊ฐ๋จํ ๋ฐฑ์๋)
- 3๊ฐ์ eureka-client ์๋น์ค
- ๊ฐ ์๋ฒ๋ -Dspring.profiles.active=peer1 or peer2 or peer3 ์ต์ ์ ํตํด ๊ตฌ๋ํ์ฌ์ผ ํฉ๋๋ค.
- ์ฌ์ฉํ๋ ํฌํธ๋ 8811-8813 ์ ๋๋ค.
- ๊ตฌ์ฑ ์ ๋ณด์ ๋ํด์ config-first-bootstrap ์ผ๋ก ๊ตฌํ๋์ด ์์ต๋๋ค.
- eureka-client-2 (๊ฐ๋จํ ๋ฐฑ์๋)
- 3๊ฐ์ eureka-client ์๋น์ค
- ๊ฐ ์๋ฒ๋ -Dspring.profiles.active=peer1 or peer2 or peer3 ์ต์ ์ ํตํด ๊ตฌ๋ํ์ฌ์ผ ํฉ๋๋ค.
- ์ฌ์ฉํ๋ ํฌํธ๋ 8821-8823 ์ ๋๋ค.
- ๊ตฌ์ฑ ์ ๋ณด์ ๋ํด์ discovery-first-bootstrap ์ผ๋ก ๊ตฌํ๋์ด ์์ต๋๋ค.
- zuul-gateway (API Gateway)
- ํฌํธ๋ 8888 ์ ๋๋ค.
- http://localhost:8888/api/client/ping ๋ก ์์ฒญ์ ์ ์กํ๋ฉด ๋ก๋๋ฐธ๋ฐ์ฑ์ด ์ ์ฉ๋ eureka-client ๋ฐฑ์๋ ํธ์ถ ์๋ต์ ๋ณด์ฌ์ค๋๋ค.
- POST http://localhost:8888/actuator/refresh ์ ํตํด ์๊ฒฉ์ ์ค์ ์ ๊ฐฑ์ ํ ์ ์์ต๋๋ค.
- hystrix-dashboard ๋ฐ turbine stream์ด ์ด ํ๋ก์ ํธ์ ํตํฉ๋์ด ์์ต๋๋ค.
- API Gateway๋ก GET http://localhost:8888/api/client/userList ์์ฒญ์ ํตํด client -> client-2 ๋ก ribbon ์ ํตํ ์์ฒญ์ ๋ ๋ฆฌ๊ณ hystrix ๋ฅผ ํตํ fallback ์ด ๋์ํฉ๋๋ค.
- http://localhost:8888/ ์์ http://localhost:8888/turbine.stream ์ ์ ๋ ฅํด turbine.stream ์ ํตํด ์ ์ฒด ๋์ค์ปค๋ฒ๋ฆฌ์ hystrix metric์ ์๊ฐํ ํ ์ ์์ต๋๋ค.
- spring-config-server (ํ์ผ ๊ธฐ๋ฐ ์๊ฒฉ ์ปจํผ๊ทธ ์๋ฒ)
- /src/main/resources/config ๋๋ ํ ๋ฆฌ ์์ ์์ ๋ชจ๋ ์๋น์ค์ ๋ํ config ํ์ผ์ด ์์นํฉ๋๋ค.
- ํ์ผ ๊ธฐ๋ฐ ๊ตฌ๋์ ์ํด -Dspring.profiles.active=native VM args ๋ก ์คํํ์ฌ์ผ ํฉ๋๋ค.
- ํฌํธ๋ 9000์ ์ฌ์ฉํฉ๋๋ค.
- admin-server (spring-boot-admin)
- http://localhost:9900 ์ผ๋ก spring-boot-admin-server๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
- Discovery๋ฅผ ๊ธฐ๋ฐ์ผ๋ก instance๋ฅผ ์๋ณํฉ๋๋ค.