Kubernetes Observability 실전: Prometheus, Grafana, Alertmanager 기반 Monitoring 및 장애 감지 시스템 구축
Kubernetes Observability 실전: Prometheus, Grafana, Alertmanager 기반 Monitoring 및 장애 감지 시스템 구축
1. Kubernetes Monitoring이 필요한 이유
Kubernetes Cluster를 운영하다 보면 다음과 같은 장애가 발생할 수 있다.
- Node CPU 사용량이 갑자기 증가한다.
- 특정 Pod의 Memory 사용량이 지속적으로 증가한다.
- Pod가 반복적으로 재시작된다.
- Node가 NotReady 상태가 된다.
- Disk 공간이 부족해진다.
- 애플리케이션 응답 시간이 증가한다.
- Kubernetes API Server 응답이 느려진다.
- 서비스 장애가 발생했지만 운영자가 늦게 발견한다.
이러한 장애를 매번 kubectl 명령어로 직접 확인하는 것은 효율적인 운영 방식이 아니다.
운영 환경에서는 Metric을 자동으로 수집하고, Dashboard를 통해 실시간으로 확인하며, 장애 조건이 발생했을 때 운영자에게 알림을 전달하는 Monitoring 시스템이 필요하다.
Kubernetes Monitoring의 대표적인 구성은 다음과 같다.
구성 요소역할PrometheusMetric 수집 및 저장GrafanaMetric 시각화 및 DashboardAlertmanagerAlert 관리 및 알림 전달Node ExporterLinux Node 시스템 Metric 제공kube-state-metricsKubernetes Object 상태 Metric 제공Kubelet / cAdvisorContainer Resource Metric 제공
이번 실습에서는 Kubernetes Cluster에 Monitoring 시스템을 구축한다.
2. Kubernetes Monitoring 전체 아키텍처
이번 교육에서는 Helm을 사용하여 Prometheus 기반 Monitoring 시스템을 설치한다.
Kubernetes Cluster
+-----------------------+
| |
| Control Plane |
| |
+-----------------------+
|
|
+-----------------------+
| |
| Worker Node |
| |
| +-----------------+ |
| | Pod | |
| | | |
| | Application | |
| +-----------------+ |
| |
| Node Exporter |
| Kubelet / cAdvisor |
| kube-state-metrics |
+-----------------------+
|
v
+-----------------------+
| Prometheus |
| |
| Metric Collection |
| Metric Storage |
| PromQL |
+-----------------------+
|
+---------+----------+
| |
v v
+---------------+ +----------------+
| Grafana | | Alertmanager |
| | | |
| Dashboard | | Alert Routing |
| Visualization | | Notifications |
+---------------+ +----------------+
Prometheus는 Kubernetes 및 Linux 시스템에서 Metric을 수집하고 저장한다.
Grafana는 Prometheus에 저장된 Metric을 조회하여 Dashboard로 표시한다.
Alertmanager는 Prometheus에서 발생한 Alert를 받아 알림 그룹화, 전달, 중복 제거 및 알림 처리 등을 담당한다.
3. 실습 환경 구성
이번 실습은 기존 Kubernetes Cluster가 구성되어 있다는 전제에서 진행한다.
3.1 실습 환경
항목구성Kuberneteskubeadm 기반 ClusterControl Plane1대 이상Worker Node2대 이상 권장OSLinuxMonitoringPrometheusDashboardGrafanaAlertAlertmanager설치 방식HelmMonitoring Namespacemonitoring
실습 환경 예시:
Kubernetes Cluster Control Plane 192.168.10.10 Worker Node 1 192.168.10.21 Worker Node 2 192.168.10.22 Worker Node 3 192.168.10.23
IP 주소는 실제 실습 환경에 맞게 변경한다.
Monitoring 시스템은 CPU, Memory, Storage를 추가로 사용하기 때문에 Resource가 부족한 Cluster에서는 설치 전에 자원 사용량을 확인해야 한다.
3.2 Cluster 상태 확인
kubectl get nodes kubectl get pods -A
Node 상태가 Ready인지 확인한다.
kubectl top nodes
kubectl top 명령어는 Metrics API가 구성되어 있어야 동작한다. Metrics API가 없더라도 Prometheus 기반 Monitoring을 구축할 수 있지만, 기존 상태를 비교하기 위해 확인해 둔다.
4. Helm 설치 및 확인
Prometheus Monitoring 시스템은 여러 구성 요소를 개별적으로 설치할 수도 있지만, 운영 환경에서는 Helm을 활용하면 구성 요소를 일관된 방식으로 배포하고 관리하기 편리하다.
Helm은 Kubernetes 애플리케이션을 패키지화하고 설치, 업그레이드, 관리할 수 있는 도구이다.
4.1 Helm 설치 확인
helm version
Helm이 설치되어 있지 않다면 Linux 환경에서 공식 Helm 설치 방법을 이용하여 설치한다.
설치 후 다음 명령어로 확인한다.
helm version
4.2 Helm Repository 추가
Prometheus, Grafana, Alertmanager 등을 통합 제공하는 kube-prometheus-stack Chart를 사용한다.
helm repo add prometheus-community \ https://prometheus-community.github.io/helm-charts
Repository 업데이트:
helm repo update
Repository 확인:
helm repo list
출력 예시:
NAME URL prometheus-community https://prometheus-community.github.io/helm-charts
4.3 Chart 확인
helm search repo prometheus-community/kube-prometheus-stack
Chart 버전 확인:
helm show chart prometheus-community/kube-prometheus-stack
실제 운영 환경에서는 설치 시점의 Chart 버전과 Kubernetes 버전 호환성을 확인하고 버전을 명시하여 설치하는 것이 좋다.
5. Monitoring Namespace 생성
Monitoring 시스템을 애플리케이션 Namespace와 분리하여 운영한다.
kubectl create namespace monitoring
Namespace 확인:
kubectl get namespaces
출력:
NAME STATUS default Active kube-system Active monitoring Active production Active
Monitoring 시스템을 별도 Namespace로 구성하면 관리, 권한, Resource 정책 및 운영 영역을 구분하기 편리하다.
6. Prometheus와 Grafana 설치
이번 실습에서는 kube-prometheus-stack Helm Chart를 이용한다.
이 Chart는 기본 구성에 따라 다음 구성 요소를 포함하거나 설치한다.
- Prometheus
- Grafana
- Alertmanager
- kube-state-metrics
- Prometheus Operator
- Node Exporter
- 관련 CRD 및 Monitoring 설정 리소스
구성은 Chart 버전 및 설정에 따라 달라질 수 있다.
6.1 Helm 설치
helm install monitoring \ prometheus-community/kube-prometheus-stack \ -n monitoring
이 명령은 Chart의 기본 설정을 이용하여 설치한다.
운영 환경에서는 기본 설정 그대로 설치하기보다는 Resource, Storage, 인증, 접근 방식, Alert 설정 등을 사전에 검토한 Values 파일을 이용하는 것을 권장한다.
6.2 설치 상태 확인
helm list -n monitoring kubectl get pods -n monitoring
출력 예시:
NAME READY STATUS monitoring-grafana-xxxx 3/3 Running monitoring-kube-prometheus-stack-xxxx 1/1 Running monitoring-kube-state-metrics-xxxx 1/1 Running monitoring-prometheus-node-exporter-xxxx 1/1 Running
Pod 이름과 개수는 Chart 버전, Cluster 구성, 설치 설정에 따라 달라질 수 있다.
6.3 설치 진행 상태 확인
kubectl get pods -n monitoring -w
Pod가 모두 정상 상태가 될 때까지 확인한다.
문제가 발생한 Pod:
kubectl describe pod <POD_NAME> -n monitoring
로그 확인:
kubectl logs <POD_NAME> -n monitoring
7. Prometheus 구성 확인
Prometheus는 Metric을 수집하고 저장하는 Monitoring 시스템의 핵심 구성 요소이다.
Prometheus는 기본적으로 Pull 방식으로 Metric을 수집한다.
Prometheus
|
| HTTP GET /metrics
|
v
Metric Exporter
|
v
Metric 반환
|
v
Prometheus 저장
Prometheus는 설정된 Target에 주기적으로 접근하여 Metric을 수집한다.
7.1 Prometheus Pod 확인
kubectl get pods -n monitoring
Prometheus Pod 확인:
kubectl get pods -n monitoring \ -l app.kubernetes.io/name=prometheus
실제 Label은 Chart 버전 및 구성에 따라 다를 수 있으므로 다음 명령으로 Label을 확인할 수도 있다.
kubectl get pods -n monitoring --show-labels
7.2 Prometheus Service 확인
kubectl get svc -n monitoring
출력 예시:
NAME TYPE CLUSTER-IP monitoring-kube-prometheus-prometheus ClusterIP 10.96.10.10 monitoring-kube-prometheus-alertmanager ClusterIP 10.96.10.11 monitoring-grafana ClusterIP 10.96.10.12
Service 이름은 Helm Release 및 Chart 설정에 따라 다르게 생성될 수 있다.
7.3 Prometheus 접근
Prometheus Service를 확인한다.
kubectl get svc -n monitoring
Prometheus Service 이름을 확인한 후 Port Forward를 실행한다.
kubectl port-forward \ -n monitoring \ svc/monitoring-kube-prometheus-prometheus \ 9090:9090
이 명령은 실행 중인 터미널을 유지해야 한다.
브라우저에서 다음 주소로 접속한다.
http://localhost:9090
<text color="success" weight="semibold">Port Forward가 정상적으로 연결되면 Prometheus Web UI에 접근할 수 있다.</text>
Port Forward는 기본적으로 로컬 접근을 위한 임시 연결이다. 운영 환경에서 직접 외부에 노출하는 방식으로 사용하지 않는 것이 좋다.
8. Prometheus Target 확인
Prometheus가 정상적으로 Metric을 수집하고 있는지 확인한다.
Prometheus Web UI에서 다음 메뉴를 선택한다.
Status | +-- Targets
Target 상태가 UP인지 확인한다.
예시:
Target상태설명kubeletUPKubelet Metricnode-exporterUPLinux Node Metrickube-state-metricsUPKubernetes Object MetricprometheusUPPrometheus 자체 Metric
Target이 DOWN 상태라면 다음을 확인한다.
- Target URL
- Service
- Endpoint
- Network
- TLS
- Authentication
- Prometheus Scrape 설정
- ServiceMonitor 설정
Target이 UP이라고 해서 모든 Metric이 정상적으로 수집된다는 의미는 아니다. 실제 Query를 실행하여 필요한 Metric이 존재하는지도 확인해야 한다.
9. Prometheus 기본 Metric 조회
Prometheus Web UI에서 Metric을 조회한다.
9.1 Prometheus 자체 상태
up
이 Metric은 Prometheus가 Target을 Scrape하는 과정에서 해당 Target의 최근 Scrape 성공 여부를 나타낸다.
9.2 Node CPU 확인
node_cpu_seconds_total
CPU 사용률 계산:
100 * (
1 -
avg by (instance) (
rate(node_cpu_seconds_total{
mode="idle"
}[5m])
)
)
9.3 Node Memory 확인
node_memory_MemTotal_bytes
사용 가능한 Memory:
node_memory_MemAvailable_bytes
Memory 사용률:
100 * ( 1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes )
9.4 Pod CPU 확인
sum by (namespace, pod) (
rate(container_cpu_usage_seconds_total{
container!="",
container!="POD"
}[5m])
)
9.5 Pod Memory 확인
sum by (namespace, pod) (
container_memory_working_set_bytes{
container!="",
container!="POD"
}
)
이 Metric들은 실제 수집 환경에 따라 Label 및 제공 여부가 다를 수 있으므로 Prometheus에서 확인한 Metric을 기준으로 Query를 작성한다.
10. Grafana Dashboard 구성
Grafana는 Prometheus Metric을 시각화하는 Dashboard 시스템이다.
Monitoring 운영에서 Grafana를 사용하면 다음 정보를 한눈에 확인할 수 있다.
- Node CPU
- Node Memory
- Node Disk
- Node Network
- Pod CPU
- Pod Memory
- Pod Restart
- Kubernetes Cluster 상태
10.1 Grafana Service 확인
kubectl get svc -n monitoring
Grafana Service를 확인한다.
예시:
monitoring-grafana
10.2 Grafana Port Forward
kubectl port-forward \ -n monitoring \ svc/monitoring-grafana \ 3000:80
브라우저에서 접속한다.
http://localhost:3000
10.3 Grafana 계정 확인
기본 설치 환경에서는 Grafana 관리자 계정이 admin으로 설정되는 경우가 일반적이며, Chart 설정에 따라 비밀번호가 생성되거나 지정된다.
Helm Chart의 기본 설정을 사용하는 경우 Secret을 확인한다.
kubectl get secrets -n monitoring
Grafana Secret 확인:
kubectl get secret monitoring-grafana \ -n monitoring
Secret에 저장된 관리자 비밀번호를 확인하는 예시:
kubectl get secret monitoring-grafana \
-n monitoring \
-o jsonpath="{.data.admin-password}" \
| base64 -d
위 Secret 이름은 Helm 설치 이름과 Chart 설정에 따라 달라질 수 있다.
Secret을 확인할 수 있는 권한이 필요하며, 관리자 계정 및 비밀번호는 운영 환경에서 변경하고 안전하게 관리해야 한다.
10.4 Grafana 로그인
로그인 화면에서 계정을 입력한다.
Username: admin Password: Secret에서 확인한 비밀번호
로그인 후 Grafana Dashboard를 확인한다.
11. Grafana Dashboard 구성 실습
11.1 Dashboard 생성
Grafana에서 다음 메뉴를 선택한다.
Dashboards
|
+-- New
|
+-- New Dashboard
Panel을 추가한다.
Add visualization
Data Source는 Prometheus를 선택한다.
11.2 Node CPU Dashboard
Query:
100 * (
1 -
avg by (instance) (
rate(node_cpu_seconds_total{
mode="idle"
}[5m])
)
)
Panel 제목:
Node CPU Usage %
Visualization:
Time series
11.3 Node Memory Dashboard
Query:
100 * ( 1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes )
Panel 제목:
Node Memory Usage %
11.4 Pod CPU Dashboard
sum by (namespace, pod) (
rate(container_cpu_usage_seconds_total{
container!="",
container!="POD"
}[5m])
)
Panel 제목:
Pod CPU Usage
11.5 Pod Memory Dashboard
sum by (namespace, pod) (
container_memory_working_set_bytes{
container!="",
container!="POD"
}
)
Panel 제목:
Pod Memory Usage
11.6 Pod Restart Dashboard
sum by (namespace, pod) ( increase(kube_pod_container_status_restarts_total[1h]) )
Panel 제목:
Pod Restart Count - Last 1 Hour
이 Query는 최근 1시간 동안의 Container Restart 증가량을 확인하는 용도로 사용한다.
11.7 Dashboard 구성 예시
+-------------------------------------------------------+ | Kubernetes Overview | +-----------------------+-------------------------------+ | Node CPU | Node Memory | +-----------------------+-------------------------------+ | Pod CPU | Pod Memory | +-----------------------+-------------------------------+ | Pod Restart | Node Disk | +-----------------------+-------------------------------+ | Node Network | Cluster Health | +-----------------------+-------------------------------+
Dashboard는 운영자가 장애 상황을 빠르게 파악할 수 있도록 구성해야 한다.
단순히 Metric을 많이 표시하는 것보다 장애 발생 시 의미 있는 정보를 제공하는 것이 중요하다.
12. Alertmanager 장애 알림 구성
Prometheus Monitoring 시스템을 구축한 이후에는 장애 발생 시 자동으로 알림을 전달하도록 구성해야 한다.
Alertmanager는 Prometheus Alert를 전달받아 다음 기능을 수행한다.
- Alert Grouping
- Alert Deduplication
- Alert Routing
- Notification
- Alert Silence
일반적인 흐름:
Metric | v Prometheus | v Alert Rule | v Alertmanager | +---- Email | +---- Slack | +---- Webhook | +---- 기타 Notification
12.1 Alert 발생 구조
예를 들어 Node CPU 사용률이 80% 이상인 상태가 5분 이상 지속되면 Alert를 발생시키도록 설정할 수 있다.
Node CPU Usage > 80%
|
v
5 Minutes
|
v
Prometheus Alert
|
v
Alertmanager
|
v
Notification
12.2 Prometheus Alert Rule
Prometheus Operator 기반 Monitoring에서는 PrometheusRule Custom Resource를 사용하여 Alert Rule을 구성할 수 있다.
다음은 Node CPU 사용률이 80% 이상인 상태가 5분 지속될 경우 Alert를 발생시키는 예시이다.
파일명:
node-cpu-alert.yaml
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: node-cpu-alert
namespace: monitoring
labels:
release: monitoring
spec:
groups:
- name: node-resource-alerts
rules:
- alert: NodeHighCPU
expr: |
100 * (
1 -
avg by (instance) (
rate(node_cpu_seconds_total{
mode="idle"
}[5m])
)
) > 80
for: 5m
labels:
severity: warning
annotations:
summary: "Node CPU usage is high"
description: "Node CPU usage has exceeded 80 percent for 5 minutes."
12.3 Alert Rule 적용
kubectl apply -f node-cpu-alert.yaml
확인:
kubectl get prometheusrule -n monitoring
Prometheus에서 Rule이 정상적으로 등록되었는지 확인한다.
Prometheus Web UI:
Alerts
또는 Prometheus Rule 관련 상태를 확인한다.
kubectl get prometheusrule -n monitoring
12.4 Alert Rule Label 확인
Prometheus Operator가 PrometheusRule을 선택하는 방식은 Prometheus 설정과 Helm Chart Values에 따라 달라질 수 있다.
설정에 따라 다음과 같은 Label이 필요할 수 있다.
labels: release: monitoring
실제 PrometheusRule이 선택되지 않는다면 Prometheus의 Rule Selector 및 Namespace Selector를 확인한다.
13. Alertmanager Email 알림 구성
Alertmanager는 다양한 알림 전달 방법을 지원한다.
이번 실습에서는 Email Notification 구성의 기본 개념을 알아본다.
Alertmanager의 SMTP 설정은 Alertmanager 설정 또는 Helm Chart Values를 통해 구성할 수 있다.
13.1 SMTP 설정 예시
다음은 개념적인 SMTP 설정 예시이다.
global:
smtp_smarthost: 'smtp.example.com:587'
smtp_from: 'monitoring@example.com'
smtp_auth_username: 'monitoring@example.com'
smtp_auth_password: 'SMTP_PASSWORD'
smtp_require_tls: true
route:
receiver: email-alert
receivers:
- name: email-alert
email_configs:
- to: 'admin@example.com'
이 설정은 Alertmanager의 설정 개념을 보여주는 예시이다.
실제 kube-prometheus-stack 환경에서는 Alertmanager의 Config를 Helm Values 또는 AlertmanagerConfig Custom Resource를 통해 구성할 수 있으며, 해당 방식에 맞게 적용해야 한다.
13.2 SMTP 설정 시 주의사항
SMTP 비밀번호를 YAML 파일에 직접 입력하여 Git Repository에 저장하지 않는다.
운영 환경에서는 다음 방법을 고려한다.
- Kubernetes Secret
- External Secrets
- Secret Management System
- SMTP 전용 계정
- SMTP 인증 정책
Alertmanager의 SMTP 설정은 사용하는 Chart 버전과 Secret 구성 방식에 맞게 적용해야 한다.
14. 실전 Alert Rule 추가
이번에는 Pod Memory 사용률 관련 Alert를 추가한다.
Pod Memory 사용량이 80% 이상인 경우 Alert를 발생시키는 예시이다.
실제 Memory Limit이 설정된 Container를 대상으로 한다.
파일명:
pod-memory-alert.yaml
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: pod-memory-alert
namespace: monitoring
labels:
release: monitoring
spec:
groups:
- name: pod-resource-alerts
rules:
- alert: PodMemoryUsageHigh
expr: |
(
container_memory_working_set_bytes{
container!="",
container!="POD"
}
/
container_spec_memory_limit_bytes{
container!="",
container!="POD"
}
) > 0.8
and
container_spec_memory_limit_bytes{
container!="",
container!="POD"
} > 0
for: 5m
labels:
severity: warning
annotations:
summary: "Pod Memory usage is high"
description: "Container Memory usage is above 80 percent of its limit."
적용:
kubectl apply -f pod-memory-alert.yaml
확인:
kubectl get prometheusrule -n monitoring
이 Alert는 Memory 사용량과 설정된 Memory Limit의 비율을 기준으로 한다.
Metric 수집 환경에 따라 Metric 이름, Label, Limit Metric 제공 여부가 달라질 수 있으므로 실제 Prometheus에서 Metric을 확인하고 적용해야 한다.
15. 장애 알림 운영 기준
Monitoring 시스템을 구축할 때 모든 Metric에 Alert를 설정하면 운영자가 알림을 과도하게 받게 된다.
이러한 상황을 Alert Fatigue라고 한다.
Alert Fatigue가 발생하면 실제 중요한 장애 알림을 놓칠 수 있다.
따라서 Alert는 중요도에 따라 구분하는 것이 좋다.
Severity의미운영 대응Critical서비스 장애 또는 심각한 위험즉시 대응Warning장애 가능성 또는 자원 위험확인 및 분석Info정보성 상태기록 및 확인
Alert 예시:
AlertSeverity조건 예시NodeNotReadyCriticalNode Ready 상태 이상 지속NodeHighCPUWarningCPU 80% 이상 5분NodeHighMemoryWarningMemory 90% 이상 지속PodCrashLoopBackOffCriticalCrashLoopBackOff 발생PodMemoryUsageHighWarningMemory Limit의 80% 이상DiskSpaceLowWarningFilesystem 여유 공간 부족DiskSpaceCriticalCriticalFilesystem 여유 공간 심각
Alert 기준은 실제 서비스의 SLA, SLO, Resource 특성에 맞게 설정해야 한다.
16. Monitoring 시스템 운영 시 주의사항
Monitoring 시스템도 Kubernetes Cluster의 일부이기 때문에 장애가 발생할 수 있다.
16.1 Prometheus Storage
Prometheus는 Metric을 저장하기 위해 Disk를 사용한다.
Storage가 부족하면 Metric 수집 및 저장에 문제가 발생할 수 있다.
운영 환경에서는 다음 사항을 고려한다.
- PersistentVolume
- PersistentVolumeClaim
- StorageClass
- Retention
- Disk 용량
- Disk I/O
- 백업
- Prometheus HA
Prometheus를 임시 Storage에 설치하면 Pod 재생성 또는 Node 장애 시 데이터가 손실될 수 있다.
운영 환경에서는 Persistent Storage 사용을 권장한다.
16.2 Monitoring Resource
Monitoring 시스템도 CPU와 Memory를 사용한다.
Cluster 규모가 커질수록 Metric 수집량과 저장량이 증가할 수 있다.
다음 항목을 고려한다.
- Prometheus CPU
- Prometheus Memory
- Prometheus Disk
- Grafana Resource
- Alertmanager Resource
- Scrape Interval
- Metric Cardinality
- Retention 기간
16.3 Metric Cardinality
Metric Label에 지나치게 많은 고유값이 포함되면 Metric Cardinality가 증가할 수 있다.
예를 들어 다음과 같은 Label은 주의해야 한다.
- 사용자 ID
- 요청 ID
- Session ID
- 임의 생성 UUID
- 개별 Transaction ID
Metric에 이러한 값을 무분별하게 포함하면 Prometheus Storage 및 Memory 사용량이 증가할 수 있다.
Metric Label은 가능한 한 제한적이고 안정적인 값으로 구성해야 한다.
17. Kubernetes Monitoring 실전 운영 점검
Monitoring 시스템 설치 이후 다음 항목을 정기적으로 확인한다.
Prometheus
kubectl get pods -n monitoring kubectl get svc -n monitoring kubectl get prometheusrule -n monitoring
Grafana
kubectl get pods -n monitoring
Dashboard 정상 접속 여부를 확인한다.
Alertmanager
kubectl get pods -n monitoring
Alert 발생 여부 및 알림 전달 여부를 확인한다.
Node Exporter
kubectl get pods -n monitoring
Node Exporter가 각 대상 Node에서 정상적으로 실행되는지 확인한다.
kube-state-metrics
kubectl get pods -n monitoring
Kubernetes Object 상태 Metric이 정상적으로 수집되는지 확인한다.
Prometheus Target
Prometheus Web UI에서:
Status | +-- Targets
Target 상태가 UP인지 확인한다.
18. Kubernetes Monitoring 구축 완료 후 운영 구조
이번 실습을 완료하면 Kubernetes Cluster에 다음 Monitoring 구조를 구성할 수 있다.
Kubernetes Cluster
|
+---------------+---------------+
| | |
v v v
Node Container Kubernetes
Exporter Metric Object
| | |
+---------------+---------------+
|
v
Prometheus
|
+-----------+-----------+
| |
v v
Grafana Alertmanager
| |
v v
Dashboard Notification
| |
v v
운영자 모니터링 장애 알림 전달
이 구조를 통해 Kubernetes Cluster의 Resource 상태를 실시간으로 확인하고 장애 발생 시 Alert를 통해 빠르게 대응할 수 있다.
19. 이번 편 핵심 정리
이번 편에서는 Kubernetes Monitoring 시스템 구축의 기본 구조와 실제 설치 및 운영 방법을 알아보았다.
- Prometheus는 Metric 수집 및 저장 시스템이다.
- Grafana는 Metric을 시각화하는 Dashboard 시스템이다.
- Alertmanager는 Alert를 관리하고 알림을 전달한다.
- Node Exporter는 Linux Node Metric을 제공한다.
- kube-state-metrics는 Kubernetes Object 상태 Metric을 제공한다.
- Kubelet 및 cAdvisor는 Container Metric 수집에 활용된다.
- Helm을 이용하면 Monitoring 시스템을 통합 설치하고 관리할 수 있다.
- Prometheus Query Language인 PromQL을 활용하여 Metric을 분석할 수 있다.
- PrometheusRule을 이용하여 Alert 조건을 정의할 수 있다.
- Monitoring 시스템도 Resource와 Storage 관리가 필요하다.
Kubernetes 운영에서 Monitoring은 단순한 시각화 시스템이 아니다.
장애를 조기에 발견하고, 장애 원인을 분석하고, 서비스의 안정성을 유지하기 위한 핵심 운영 체계이다.
Monitoring 시스템이 구축되어 있어야 장애가 발생했을 때 과거 Metric을 비교하고, 장애 발생 시점의 CPU, Memory, Disk, Network 상태를 분석할 수 있다.
다음 편 예고
36편 — Kubernetes Logging 실전: Loki, Promtail/Alloy, Grafana 기반 Container Log 수집 및 장애 분석 시스템 구축
다음 편에서는 Kubernetes Cluster에서 발생하는 Container Log를 중앙 집중식으로 수집하고, Loki와 Grafana를 이용하여 Pod, Namespace, Node별 로그를 검색하고 분석하는 Logging 시스템을 구축한다.
실제 장애 발생 시 로그와 Metric을 함께 분석하는 운영 환경을 구성하는 것이 다음 편의 목표이다.
다음 편에서는 Loki 기반 중앙 집중식 로그 시스템을 구축하고, Prometheus의 Metric과 Kubernetes 로그를 연결하여 실제 장애 분석에 활용하는 방법으로 이어가겠습니다.
댓글
아직 댓글이 없습니다.
로그인 후 댓글을 남길 수 있습니다.