Skip to content

gnu-gnu/spring-cloud-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

spring-cloud-example

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๋ฅผ ์‹๋ณ„ํ•ฉ๋‹ˆ๋‹ค.

About

Example for Spring cloud (netflix OSS, spring cloud)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages