본문 바로가기
PROMETHEUS

prometheus operator 간단 설치 (NodePort 사용)

by 정윤재 2023. 6. 2.

1. prometheus operator git clone

 

git clone https://github.com/prometheus-community/helm-charts.git

 

2. 설치를 위한 namespace 생성

 

shell> kubectl create namespace monitor

 

3. prometheus tsdb 데이터가 저장 pv 생성

 

kube-pv.yaml

 

apiVersion: v1

kind: PersistentVolume

metadata:

  name: kube-pv

spec:

  capacity:

    storage: 1Gi # 스토리지 용량 1GB

  volumeMode: Filesystem # 파일 시스템 형식

  accessModes: # 읽기/쓰기 옵션

  - ReadWriteOnce

  storageClassName: manual

  persistentVolumeReclaimPolicy: Retain

  hostPath:

    path: /tmp/prometheus # worker node 의 local Path

* worker node 에 /tmp/prometheus 경로가 있어야 하고 쓰기 권한도 있어야 한다.

 

shell> kubectl apply -f kube-pv.yaml

 

4. helm chart 설치

 

cd helm-charts/charts/kube-prometheus-stack

 

helm dependency update

 

vi values.yaml 에서 ClientIP 설정 되어 있는 것들을 고침 (NodePort)

 

나의 경우 baremetal 에 native k8s 설치 후 prometheus 설치 하는 것이므로

 

grafana 사용은 false 변경 (이건 loadbalancer 타입이 기본인듯함)

 

 

만들어 놓은 pv 대해 values.yaml 아래와 같이 storageclass 설정

 

    storageSpec:

    ## Using PersistentVolumeClaim

    ##

      volumeClaimTemplate:

        spec:

          storageClassName: manual

          accessModes: ["ReadWriteOnce"]

          resources:

            requests:

              storage: 1Gi

 

pvc 자동으로 생성 되어 bound

 

shell> helm install -f values.yaml prometheus --namespace=monitor .

 

http://192.168.101.145:30090/ 

로 브라우저 접속 하면 prometheus 접속이 된다.

 

192.168.101.145 나의 worker node ip 이다.(각자의 환경에 맞게 ip 를 설정 하면 된다.

 

prometheus 화면

 

'PROMETHEUS' 카테고리의 다른 글

메트릭 (metric) 이란  (0) 2023.06.19
prometheus 에서 no space left on device 에러 발생시  (0) 2023.05.29

댓글