본문 바로가기
[GPUaaS]/Prometheus

[NCP 실전] Kubernetes에 Prometheus + Grafana 모니터링 구성

by METAVERSE STORY 2026. 1. 12.
반응형

 

 

NCP(Naver Cloud Platform) Kubernetes에 Prometheus + Grafana 모니터링 구성하는 상세 단계별 가이드입니다.
NCP K8s환경에서도 일반 Kubernetes와 동일하게 Helm을 활용해 설치할 수 있습니다.


📌 사전 준비

  • kubectl이 클러스터에 연결되어 있어야 함
  • helm 3 이상 설치
  • (선택) Namespace 별로 설치 권장 예: monitoring

📌 1) Helm 설치 (만약 없다면)

 

# Helm 설치 스크립트 다운로드
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3

# 실행 권한 부여 & 설치
chmod 700 get_helm.sh
./get_helm.sh

(Helm은 Kubernetes 패키지 매니저입니다)

 


📌 2) Helm 리포지토리 추가

 

# Prometheus + Grafana를 포함한 커뮤니티 차트
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

# Grafana 공식 차트(별도 설치 원하는 경우)
helm repo add grafana https://grafana.github.io/helm-charts

# 리포 업데이트
helm repo update

 


📌 3) Namespace 생성

 
kubectl create namespace monitoring

Namespace를 따로 두면 관리가 훨씬 편합니다.

 

 


📌 4) Prometheus + Grafana 설치 (kube-prometheus-stack)

가장 간단한 방법은 kube-prometheus-stack 차트를 이용하는 것입니다.
이 차트는 Prometheus(서버, node-exporter, kube-state-metrics, Alertmanager 포함) 와 Grafana 를 모두 설치합니다. IT Infra Management

 
helm install prometheus prometheus-community/kube-prometheus-stack --namespace monitoring


설치 확인:

kubectl get pods -n monitoring
 
 
 

 


📌 5) Grafana & Prometheus 접근

🔹 Prometheus UI

 
kubectl port-forward -n monitoring svc/prometheus-operated 9090:9090

브라우저에서 → http://localhost:9090 접속

 

 


🔹 Grafana UI

 
# 포트포워딩
 
kubectl port-forward -n monitoring svc/prometheus-stack-grafana 3000:80

브라우저에서 → http://localhost:3000 접속

기본 로그인 정보:

 
# 비밀번호 확인
 
kubectl get secret -n monitoring prometheus-stack-grafana -o jsonpath="{.data.admin-password}" \ | base64 --decode ; echo
 
 
# 보통 사용자명은 admin 입니다

AirTips

참고: 차트에 따라 서비스 이름이 조금 다를 수 있습니다. kubectl get svc -n monitoring 으로 실제 이름을 확인하세요.

 

 

 


📌 6) Grafana Data Source 설정

대부분의 경우 Helm chart가 자동으로 Prometheus를 DataSource로 등록해줍니다.
만약 안된 경우, 아래처럼 수동 등록 가능:

  1. Grafana UI 접속 → Configuration > Data Sources
  2. Prometheus 선택
  3. URL: http://prometheus-operated.monitoring.svc.cluster.local:9090
  4. Save & Test

 

 


📌 7) 추천 Grafana 대시보드

설치 후 Grafana 기본 메뉴에 이미 여러 대시보드가 포함되어 있을 수 있지만, 더 확실한 추천은 아래 대시보드입니다.

🔹 Kubernetes 모니터링 대시보드

  • Kubernetes / Compute Resources / Cluster
  • Kubernetes / Compute Resources / Namespace (Pods)
  • Kubernetes / Compute Resources / Node
  • Kubernetes / Cluster Monitoring (prometheus-operator)

이들은 클러스터 전체, 네임스페이스별, 노드별 메트릭을 시각화해줍니다. 뭉게뭉게 클라우드


📌 8) 대시보드 가져오기 (Import)

  1. Grafana UI → + (Create) > Import
  2. 아래 대시보드 ID 또는 JSON 입력

📌 대표적인 커뮤니티 Dashboard IDs:

목적 Grafana Dashboard ID
Kubernetes Cluster Monitoring 315
K8s Compute Resource Usage 6417
K8s CPU / Memory / Network 11074
Namespace Pod Monitoring 8588

Grafana 커뮤니티 대시보드 사이트에서 ID 검색 후 Import 가능.

 

 

 


📌 9) 실제 서비스 Exporter 추가 (선택)

기본적으로 kube-prometheus-stack은 다음을 포함합니다:

  • kube-state-metrics
  • node-exporter
  • cAdvisor 메트릭

추가로 application metrics 수집 원하면, 해당 서비스에 ServiceMonitor 리소스를 만들어 등록해야 합니다.
예:

 
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: myapp-monitor
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: myapp
  endpoints:
  - port: metrics
 
 
 
 

kubectl apply -f service-monitor.yaml

이렇게 하면 Prometheus가 자동으로 이 서비스의 /metrics 를 수집합니다.

 

 


🔎 요약

✔ Helm 설치 및 repo 등록
✔ monitoring Namespace 생성
✔ kube-prometheus-stack 설치 (Prometheus + Grafana 포함)
✔ Grafana / Prometheus UI 접속
✔ 추천 대시보드 Import

 

 

 

 

반응형

댓글