diff --git a/README.md b/README.md index 8e76579..dde752f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ +### 새 마이크로서비스 추가 시 체크리스트 +- [ ] 새 마이크로서비스를 위한 secret 이 작성되었나요? +- [ ] 새 마이크로서비스에 대한 deployment yaml 파일이 작성되었나요? +- [ ] 새 마이크로서비스에 대한 service yaml 파일이 작성되었나요? +- [ ] 새 마이크로서비스를 향한 API Gateway 설정이 작성되었나요? +- [ ] Dockerfile 이 작성되었나요? +- [ ] 새 마이크로서비스에 대한 CI/CD 파이프라인이 작성되었나요? +- [ ] 코파일럿 코드 리뷰를 위한 instructions가 작성되었나요? + ### 새 API 버전 추가 시 주의할 점 - [ ] 새 API 버전에 대한 경로의 인증 필터링이 정상적으로 동작하나요? - [ ] 프론트엔드에서 기존 API 버전도 정상적으로 동작하나요? diff --git a/build.gradle b/build.gradle index f972125..9369d35 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,8 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-security' + runtimeOnly 'io.micrometer:micrometer-registry-prometheus' + // JWT implementation 'io.jsonwebtoken:jjwt-api:0.12.5' runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.5' diff --git a/k8s/gateway-metrics.yaml b/k8s/gateway-metrics.yaml new file mode 100644 index 0000000..642a411 --- /dev/null +++ b/k8s/gateway-metrics.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: gateway-metrics-service + namespace: pinit +spec: + selector: + app: pinit-gateway + ports: + - protocol: TCP + port: 9095 + targetPort: 9095 + type: NodePort + \ No newline at end of file diff --git a/src/main/java/me/pinitgateway/security/SecurityConfig.java b/src/main/java/me/pinitgateway/security/SecurityConfig.java index 5801e82..52801a3 100644 --- a/src/main/java/me/pinitgateway/security/SecurityConfig.java +++ b/src/main/java/me/pinitgateway/security/SecurityConfig.java @@ -48,7 +48,7 @@ public SecurityWebFilterChain mainSecurityFilterChain(ServerHttpSecurity http, JwtAuthenticationFilter jwtAuthenticationFilter) { return applyCommon(http) .authorizeExchange(auth -> auth - .pathMatchers("/actuator/health/liveness", "/actuator/health/readiness", "/v3/**", "/swagger-ui/**", "/async-api/**").permitAll() + .pathMatchers("/actuator/prometheus", "/actuator/health/liveness", "/actuator/health/readiness", "/v3/**", "/swagger-ui/**", "/async-api/**").permitAll() .anyExchange().authenticated() ) .addFilterAt(jwtAuthenticationFilter, SecurityWebFiltersOrder.AUTHENTICATION) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 46cdbdf..bde6f74 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -22,6 +22,15 @@ spring: - Host=localhost:8080 filters: - JwtSubToMemberIdHeader + metrics: + enabled: true +management: + server: + port: 9096 + endpoints: + web: + exposure: + include: "health,info,metrics,prometheus" server: port: 8060 diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 18b9468..6771c68 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -22,6 +22,16 @@ spring: - Host=api.pinit.go-gradually.me filters: - JwtSubToMemberIdHeader + metrics: + enabled: true +management: + server: + port: 9095 + endpoints: + web: + exposure: + include: "health,info,metrics,prometheus" + path: key: