-
Kubernetes(K8S): Helm + Prometheus + Grafana공부합시다!/Kubernetes 2023. 1. 6. 00:15728x90
오늘은 K8S의 패키지 관리 echo system인 helm을 이용해서 Prometheus Stack을 설치합니다.
1. Helm: K8S chart(Package) 관리 시스템
2. Prometheus Stack
2.1. Prometheus: K8S Resource Mornitoring System(CPU, Memory 위주)
2.2. Grafana: Mornitoring System 시각화
3. 설정 변경 후 확인
순서로 진행하겠습니다.
1. Helm: K8S chart(Package) 관리 시스템
1.1. helm 설치 스크립트 다운로드 및 실행
1.2. repository 구성 및 update
1.3. 간단한 Helm 사용법
1.3.1. 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
1.3.2. 공식 리포지토리 추가, mysql chart 설치 및 삭제
# helm repo add stable https://charts.helm.sh/stable helm 공식 리포지토리 추가 # helm search repo 리포지토리 chart 확인 # helm repo update 리포지토리 업데이트 # helm install stable/mysql --generate-name mysql 설치 # helm list helm으로 설치된 chart 확인 # helm uninstall mysql-1672897024 # helm list chart 삭제 후 확인
2. Prometheus Stack
2.1. chart 확인 및 설치
2.2. pod, service, secret 확인
2.2.1. service는 clusterIP -> NodePort로 변경
2.2.2. secret에서 grafana admin 의 password 확인
# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts prometheus 리포지토리 추가 # helm search repo prometheus prometheus chart 확인 prometheus-community/kube-prometheus-stack 설치 # helm install prometheus-community/kube-prometheus-stack --generate-name kube-prometheus-stack chart설치 # kubectl get pods,svc,deployment,secret -o wide 설치 후 확인 사항 service/kube-prometheus-stack-1672897171-grafana ClusterIP 10.100.152.134 <none> 80/TCP ClusterIP를 NodePort 변경 예정 secret/kube-prometheus-stack-1672897171-grafana Opaque 3 70s secret의 admin passwordk 확인 예정
3. 설정 변경 후 확인
3.1. service NodePort 변경
3.2. 패스워드 확인, 접속
# kubectl edit service/kube-prometheus-stack-1672897171-grafana ClusterIP -> NodePort로 변경 # kubectl get svc kube-prometheus-stack-1672897171-grafana NodePort 10.100.152.134 <none> 80:30988/TCP nodeport 30988 확인 추후 웹브라우저로 접속 # kubectl get secret/kube-prometheus-stack-1672897171-grafana -o jsonpath="{.data.admin-password}"|base64 --decode;echo secret 리소스에서 admin password 를 확인하는 jsonpath 사용 admin password는 prom-operator
주의) 위에서 jsonpath 경로는 .data.admin-password 가 되는 이유는
.파일 전체를 의미
.data 파일에서 data 영역
. data.admin-password 영역
파일을 grafana의 secret의 resource를 kubectl edit 명령어로 open 합니다.
아래 빨간부분이 보이시죠! josnpath는 이렇게 설정합니다.
그냥 저 패스워드를 디코딩하셔도 아래와 동일합니다.
3.3. Test
3.3.1. 모든nodeIP:nodeport
4. 삭제
4.1. 설치된 helm chart 확인
4.2. helm uninstall 삭제
4.3. 남은 Resource는 수동 삭제
# helm uninstall kube-prometheus-stack-1672897171 # kubectl get pods,svc,deployment,secret -o wide NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 12d <none> NAME TYPE DATA AGE secret/kube-prometheus-stack-1672-admission Opaque 3 92m # kubectl delete secret/kube-prometheus-stack-1672-admission secret "kube-prometheus-stack-1672-admission" deleted # kubectl get pods,svc,deployment,secret -o wide
자! 지금까지 helm, prometheus stack을 활용하여 prometheus와 Grafana 까지 구성해 보았습니다.
728x90'공부합시다! > Kubernetes' 카테고리의 다른 글
Kubernetes (K8S): pull rate limit 해결 - Secret Base (0) 2023.03.31 Kubernetes(K8S): kubeclt cp 와 tar 다중 파일 복사 (0) 2023.01.07 Kubernetes(K8S): DaemonSet & StatefulSet (0) 2023.01.04 Kubernetes(K8S): Job & CronJob (0) 2023.01.03 Kubernetes(K8S): Multi Container POD (0) 2023.01.02