Helm으로 Prometheus 배포하기
Helm으로 Prometheus 배포하기
Amazon Managed Service for Prometheus를 사용하는 대안으로, Helm으로 클러스터에 Prometheus를 배포할 수 있어요. Helm이 이미 설치되어 있다면 helm version 명령으로 버전을 확인할 수 있어요. Helm은 Kubernetes 클러스터용 패키지 관리자예요. Helm과 설치 방법에 대한 자세한 내용은 Amazon EKS에서 Helm으로 애플리케이션 배포하기를 참고하세요.
Amazon EKS 클러스터용 Helm을 구성한 뒤에는 다음 단계로 Prometheus를 배포할 수 있어요.
출처: 문서
본문
- Prometheus 네임스페이스를 만듭니다.
kubectl create namespace prometheus
prometheus-community차트 저장소를 추가합니다.
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
- Prometheus를 배포합니다.
helm upgrade -i prometheus prometheus-community/prometheus \
--namespace prometheus \
--set alertmanager.persistence.storageClass="gp2" \
--set server.persistentVolume.storageClass="gp2"
참고
이 명령을 실행할 때
Error: failed to download "stable/prometheus" (hint: running helm repo update may help)오류가 발생하면helm repo update prometheus-community를 실행한 다음 3단계 명령을 다시 실행하세요.
Error: rendered manifests contain a resource that already exists오류가 발생하면helm uninstall your-release-name-nnamespace를 실행한 다음 3단계 명령을 다시 실행하세요.
prometheus네임스페이스의 모든 Pod가READY상태인지 확인합니다.
kubectl get pods -n prometheus
출력 예시는 다음과 같아요.
NAME READY STATUS RESTARTS AGE
prometheus-alertmanager-59b4c8c744-r7bgp 1/2 Running 0 48s
prometheus-kube-state-metrics-7cfd87cf99-jkz2f 1/1 Running 0 48s
prometheus-node-exporter-jcjqz 1/1 Running 0 48s
prometheus-node-exporter-jxv2h 1/1 Running 0 48s
prometheus-node-exporter-vbdks 1/1 Running 0 48s
prometheus-pushgateway-76c444b68c-82tnw 1/1 Running 0 48s
prometheus-server-775957f748-mmht9 1/2 Running 0 48s
kubectl로 Prometheus 콘솔을 로컬 머신으로 포트 포워딩합니다.
kubectl --namespace=prometheus port-forward deploy/prometheus-server 9090
- 웹 브라우저에서
http://localhost:9090으로 이동해 Prometheus 콘솔을 봅니다. - insert metric at cursor 메뉴에서 지표를 선택한 다음 Execute를 선택합니다. 시간에 따른 지표를 보려면 Graph 탭을 선택합니다. 아래 이미지는 시간에 따른
container_memory_usage_bytes를 보여줘요. - 위쪽 탐색 모음에서 Status를 선택한 다음 Targets를 선택합니다.
- 서비스 디스커버리를 사용해 Prometheus에 연결된 모든 Kubernetes 엔드포인트가 표시됩니다.