mingming

EKS Prometheus & Grafana 본문

kubernetes

EKS Prometheus & Grafana

mingming_96 2023. 8. 31. 12:39

Prometheus와 Grafana를 통한 모니터링 시스템 구축하기 

 

사전 준비 사항 

 

helm 설치가 되어 있어야 합니다. 

 

aws cli , kubectl, eksctl 명령어가 설치되어 있어야 합니다.

 

monitoring namespace를 생성해 줍니다.

 

목표 구성도

 

실습환경

instance : cloud9

instancetype: t2.micro

eks cluster : node 1 , t3.small

 

EKS Cluster Provisioning

eks cluster 구현

eksctl create cluster --name <cluster_name> --version 1.24 \
	--region ap-northeast-2 \
	--nodegroup-name linux-noded \
	--nodes 1 --nodes-min 1 --nodes-max 4 \
	--ssh-access --ssh-public-key <Key_name> --node-type t3.small --managed

 

namespace

prometheus & grafana 를 배포할 namespace를 생성

kubectl create namespace monitoring

 

Prometheous & Grafana 설치 

helm 을 통해 설치합니다 .

 

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

 

helm repo add

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

helm repo update

 

values.yaml

helm install 하기 전 grafana 변수를 정의하는 values.yaml 파일을 다운받아 줍니다.

wget https://github.com/grafana/helm-charts/blob/main/charts/grafana/values.yaml

 

helm install

helm install prometheus prometheus-community/kube-prometheus-stack -f "values.yaml" --namespace monitoring

 

설치가 완료되면 다음과 같이 나옵니다.

NAME: prometheus
LAST DEPLOYED: Thu Aug 31 02:31:49 2023
NAMESPACE: monitoring
STATUS: deployed
REVISION: 1
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
  kubectl --namespace monitoring get pods -l "release=prometheus"

Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.

 

Prometheus가 정상적으로 작동중인지 확인합니다.

kubectl get pods -n monitoring

 

grafana 실행

grafana의 포트를 localhost 3000번 포트로 변경해줍니다 

kubectl port-forward service/prometheus-grafana 3000:80 --namespace monitoring

lcoal host 3000 번 포트로 접속해 줍니다.

 

username : admin 

password : prom-opreator 

 

실습이 마무리 되었으면 클러스터를 삭제해 줍니다. 

eksctl delete cluster --name <cluster_name> --region ap-northeast-2

'kubernetes' 카테고리의 다른 글

Vagrant로 kubernetes Cluster 구축하기  (0) 2023.09.01
Kubernetes Pod Resoure 할당하기  (0) 2023.08.31
kubernetes static Pod  (0) 2023.08.30
kubernets Metal LB 설치하기  (0) 2023.08.30
kubernetes init container  (0) 2023.08.29