Prometheus
namespace 생성
⇒ prometheus 만의 논리적인 공간을 할당해준다.
ClusterRole, ClusterRoleBinding, ServiceAccount 생성
⇒ Kubernetes Cluster 내의 api에 접근할 수 있는 권한을 Prometheus가 부여받기 위한 작업
⇒ ClusterRole ↔ ClusterRoleBinding ↔ ServiceAccount
⇒ ClusterRoleBinding은 바인딩만 해주는 api 리소스이므로 namespace를 지정하지 않음
ConfigMap 생성
⇒ Configuration File 정의
⇒ prometheus.rules : Metric에 대한 Alarm 조건을 지정, 특정 조건 달성 시 AlertManager로 알람을 보냄
⇒ prometheus.yml : Metric의 종류, 수집 주기
Deployment 생성
Service 생성
node exporter
→ Kubernetes 기본 System metric 외의 것들을 수집하기 위해 Agent를 따로 둠
→ 각각 하나씩 DaemonSet으로 띄워줌
kube-state-metrics
→ 쿠버네티스 클러스터 내 Object (Pod, ..)에 대한 지표 정보를 생성하는 서비스
→ Pod 상태 정보를 Monitoring하기 위해 kube-state-metrics가 있어야 함
Grafana
Prometheus - Grafana 연동
Grafana Dashboard에서 Prometheus의 정보를 넣어주어야 한다.
Endpoint는 Prometheus Service의 ClusterIP를 기입해주어야 서로 파드 간의 통신이 가능하다.
Dashboard 추가
## prometheus directory
kubectl create -f prometheus-cm.yaml
kubectl create -f prometheus-crb.yaml
kubectl create -f prometheus-cr.yaml
kubectl create -f prometheus-deployment.yaml
kubectl create -f prometheus-svc.yaml
kubectl create -f prometheus-node-exporter.yaml
## kube-state directory
kubectl create -f kube-state-crb.yaml
kubectl create -f kube-state-cr.yaml
kubectl create -f kube-state-sa.yaml
kubectl create -f kube-state-deployment.yaml
kubectl create -f kube-state-svc.yaml
## grafana directory
kubectl create -f grafana-deployment.yaml
kubectl create -f grafana-svc.yaml
[root@k-master monitoring]# tree
.
├── grafana
│ ├── grafana-deployment.yaml
│ └── grafana-svc.yaml
├── kube-state
│ ├── kube-state-crb.yaml
│ ├── kube-state-cr.yaml
│ ├── kube-state-deployment.yaml
│ ├── kube-state-sa.yaml
│ └── kube-state-svc.yaml
└── prometheus
├── prometheus-cm.yaml
├── prometheus-crb.yaml
├── prometheus-cr.yaml
├── prometheus-deployment.yaml
├── prometheus-node-exporter.yaml
└── prometheus-svc.yaml
3 directories, 13 files
[root@k-master monitoring]# kubectl get svc -n monitoring
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
grafana NodePort 10.111.13.96 <none> 3000:30004/TCP 14m
prometheus-service NodePort 10.104.146.174 <none> 8080:30003/TCP 35m