Infra/IaC

[k8s] 모니터링 : Prometheus & Grafana (nginx ingress 설정까지)

jykim23 2023. 11. 26. 17:51

https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack

 

# helm repo 설정

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update

# 바로 설치 : helm install prom-stack prometheus-community/kube-prometheus-stack

 

# 설치 옵션 설정

helm pull prometheus-community/kube-prometheus-stack

tar xf kube-prometheus-stack-54.2.1.tgz

cd kube-prometheus-stack/

 

vi values.yaml

adminPassword: passwd # 초기값 변경

adminPassword 변경

 

# 설치

helm install --create-namespace prom-stack . -n monitoring -f values.yaml

삭제 : helm delete prom-stack -n monitoring

 

#  접속 테스트 - 포트포워딩

kubectl port-forward --address 0.0.0.0 -n monitoring svc/prom-stack-grafana 9000:80 &

kubectl port-forward --address 0.0.0.0 -n monitoring svc/prom-stack-kube-prometheus-prometheus 9091:9090 &

curl 응답 확인.

 

# Grafana - nginx ingress 설정

https://github.com/grafana/helm-charts/blob/main/charts/grafana/README.md#example-ingress-with-path

1. grafana.ini : vi kube-prometheus-stack/charts/grafana/values.yaml

root_url, serve_from_sub_path 설정

2. prometheus-stack : vi kube-prometheus-stack/values.yaml

ingress 설정

 

 

재배포 및 접속 확인

재배포: helm upgrade prom-stack . -n monitoring -f values.yaml

접속: http://host/grafana

계정정보:

username: kubectl get secret --namespace monitoring prom-stack-grafana -o jsonpath="{.data.admin-user}" | base64 --decode ; echo

password: kubectl get secret --namespace monitoring prom-stack-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

root_url: /grafana/

 

 

# Prometheus 연결 확인

Connections > Data sources

 

 

 

# 대시보드 설정

기본 지원 대시보드

 

 

 

작성중...