정리노트

[MSA]

컵라면만두세트 2022. 6. 30. 20:11

키워드

  • DEVOPS
  • MSA
  • EUREKA
  • JENKINS
  • AWS
  • EC2

서버


MSA

  • dependcy 추가

 

클라


  • application.yml
server:
  port: 9000

spring:
  application:
    name: discovery client1

eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: <http://127.0.0.1:8761/eureka>

GateWay


  • application.yml
server:
  port: 8000

eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: <http://127.0.0.1:8761/eureka>

spring:
  application:
    name: gateway-service
  cloud:
    gateway:
      routes:
        - id: discovery client1
          uri: <http://localhost:9000/>
          predicates:
            - Path=client1/**
        - id: discovery client2
          uri: <http://localhost:9001/>
          predicates:
            - Path=client2/**

결과


  • DISCOVERY CLIENT1 이라는 이름으로 EUREKA(CLIENT1)8761 서버에 등록

  • netty 사용 → 동기언어 (webflux?)

사용해보면 좋은것


개인 서버 만들기


userService

  • 9000 포트

postService

  • 9001포트

gateWay

  • 8000포트
  • config → config 파일을 올림으로써 혹시나 코드가 탈취당했다고 해도, git config에 db정보를 올려뒀기때문에 안전
  • YML 파일에서 필요한 filter 적용과 user, post 넘어오는걸 등록
  • cors 적용

 

globalcors:
        cors-configurations:
          '[/**]':
            allowedMethods:
              - GET
              - POST
              - DELETE
              - PUT
              - OPTION
            allowedOrigins:
              - "<http://localhost:3000>"
            allowedHeaders: "*"

Eureka

  • 8761포트

Swagger

Config

  • 필요한 설정파일을 불러온다
  • git
    • yml 3가지 파일 (dev, prd, config)