-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/프로메테우스 연결 #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/프로메테우스 연결 #17
The head ref may contain hidden characters: "feat/\uD504\uB85C\uBA54\uD14C\uC6B0\uC2A4-\uC5F0\uACB0"
Conversation
# Conflicts: # src/main/resources/application-prod.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
이 PR은 Spring Boot Actuator와 Prometheus를 연동하여 애플리케이션 메트릭 모니터링 기능을 추가합니다.
주요 변경사항:
- Prometheus 메트릭 수집을 위한 별도 관리 포트(9095) 추가
- Kubernetes에 메트릭 노출용 NodePort 서비스 생성
- Health check endpoint를 관리 포트로 통합
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| build.gradle | Micrometer Prometheus 레지스트리 의존성 추가 |
| src/main/resources/application-prod.yml | 관리 포트 9095 설정 및 actuator endpoints 노출 구성 |
| k8s/task-metrics.yaml | Prometheus 메트릭 수집을 위한 NodePort 서비스 정의 (신규) |
| k8s/deployment.yaml | Health check probe를 관리 포트(9095)로 변경 |
| endpoints: | ||
| web: | ||
| exposure: | ||
| include: "health,info,metrics,prometheus" |
Copilot
AI
Dec 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
문제점: metrics, prometheus endpoint가 인증 없이 공개적으로 노출되고 있으며, NodePort 타입의 서비스를 통해 외부에서 직접 접근 가능합니다. 현재 프로젝트에는 Spring Security 설정이 없어 누구나 애플리케이션의 모든 메트릭 정보에 접근할 수 있습니다.
영향:
- 시스템 리소스 사용량, DB 연결 정보, 애플리케이션 내부 구조 등 민감한 정보가 노출될 수 있습니다
- NodePort 30096을 통해 클러스터 외부에서도 접근 가능하여 보안 위험이 높습니다
수정 제안:
- management endpoints에 대한 보안 설정을 추가하거나
- Prometheus가 클러스터 내부에서만 scrape하도록 Service 타입을 ClusterIP로 변경하고
- application-prod.yml에 management.endpoints.web.exposure.include를 최소한으로 제한하는 것을 고려하세요 (예: "health,prometheus"만 노출)
| - protocol: TCP | ||
| port: 9095 | ||
| targetPort: 9095 | ||
| nodePort: 30096 | ||
| type: NodePort |
Copilot
AI
Dec 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
문제점: NodePort 타입의 서비스를 사용하여 metrics endpoint를 외부에 노출하고 있습니다. Prometheus는 일반적으로 클러스터 내부에서 실행되며 scrape 대상에 접근할 수 있습니다.
영향:
- 불필요하게 외부 포트(30096)를 열어 보안 공격 표면을 넓힙니다
- 외부에서 민감한 애플리케이션 메트릭에 접근할 수 있습니다
수정 제안: Prometheus가 클러스터 내부에 설치되어 있다면, Service 타입을 ClusterIP로 변경하는 것을 권장합니다:
type: ClusterIP그리고 nodePort 필드는 제거하세요. 외부에서 메트릭을 확인해야 한다면 kubectl port-forward를 사용하거나 Ingress를 통해 인증을 추가하세요.
| metadata: | ||
| name: task-metrics-service | ||
| namespace: pinit | ||
| spec: |
Copilot
AI
Dec 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
문제점: task-metrics.yaml 서비스에 Prometheus가 자동으로 메트릭을 수집할 수 있도록 하는 annotations이 없습니다. Prometheus Operator를 사용하는 경우 ServiceMonitor를 통해 설정하거나, annotation 기반 자동 검색을 사용할 수 있습니다.
영향: Prometheus가 이 서비스를 자동으로 발견하지 못해 수동으로 scrape 설정을 추가해야 할 수 있습니다.
수정 제안: Prometheus의 설정 방식에 따라 다음 중 하나를 고려하세요:
- Prometheus Operator를 사용한다면 ServiceMonitor 리소스를 생성
- annotation 기반 자동 검색을 사용한다면 metadata.annotations에 다음을 추가:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9095"
prometheus.io/path: "/actuator/prometheus"| management: | ||
| server: | ||
| port: 9095 | ||
| endpoints: | ||
| web: | ||
| exposure: | ||
| include: "health,info,metrics,prometheus" |
Copilot
AI
Dec 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
문제점: application-prod.yml에만 management 설정이 추가되어 있고, application-dev.yml에는 해당 설정이 없습니다. 이로 인해 dev 환경에서는 actuator endpoint가 기본 8080 포트에서 제공되는 반면, deployment.yaml의 health check는 모든 환경에서 9095 포트를 사용하도록 변경되었습니다.
영향: dev 환경에서 애플리케이션을 실행할 때 health check가 실패하여 pod가 정상적으로 시작되지 않을 수 있습니다.
수정 제안: application-dev.yml에도 동일한 management 설정을 추가하거나, 환경별로 다른 health check 포트를 사용하도록 deployment 설정을 분리해야 합니다. 일관성을 위해 dev 환경에도 동일한 설정을 추가하는 것을 권장합니다.
변경된 점