나이는 지구가 태양을 도는 횟수일 뿐이다.
K8s 모니터링 하기 [prometheus,grafana] 본문
클러스터 모니터링하기
- prometheus , Grafana 항상 등장하길래 해보고싶다.
- 지난번 구축한 ArgoCD를 사용해서 배포
Helm차트 생성하기
- artifacthub.io 에서 prometheus 를 검색하니 kube-prometheus-stack에 별이 많아서 사용해보았다.
- https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
kube-prometheus-stack 44.2.1 · prometheus/prometheus-community
kube-prometheus-stack collects Kubernetes manifests, Grafana dashboards, and Prometheus rules combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.
artifacthub.io
차트 pull 및 수정
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm pull prometheus-community/kube-prometheus-stack
tar zxvf .\kube-prometheus-stack-44.1.0.tgz
- Values.yaml에서 원하는 값을 수정합니다.
- 제가 테스트용으로 원하는값은 프로메테우스의 데이터 기간과 저장소값 그리고 Grafana의 서비스 타입입니다.
prometheus:
prometheusspec:
retention: 30d ## 30일 이후 데이터 삭제
storageSpec:
volumeClaimTemplate:
spec:
storageClassName: standard ## 클라우드 공급자에 따라 다릅니다. EKS경우 gp2 등등..
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 100Gi
grafana:
service:
portName: http-web
type: LoadBalancer ## 외부노출 로드밸런서로 수정 (해당값은 없으니 넣어주시면됩니다.)
- 저장하고 이전에 ArgoCD와 연결된 git에 push해줍니다.
Argo-CD로 배포
- Argo-CD에서 배포해보겠습니다.
- 좌측 상단의 NewApp을 누른후 기본 정보를 입력해줍니다.
- 소스에서 기존에 연결되었던 깃 저장소를 선택해주고 push했던 폴더 이름을 선택해줍니다.
- 목적지로 로컬클러스터 주소를 지정해주고 네임스페이스를 기입해줍니다. [저는 미리만들어두었습니다.]
그리고 저희는 Values파일을 수정해두었기떄문에 Values Files를 지정해줍니다.
- create를 눌러주면 네모모양으로 상태가 보여지는 여기서 SYNC를 누르게되면 배포가 진행됩니다.
- 하지만 사용하는 차트의 기본 제공대시보드를 사용한다면 해당 json 내요의 리소스사양이 너무커서 배포가 되지않습니다.하여 Sync 간에 Replace 옵션을 체크하여 배포를하겠습니다.
참조: https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#replace-resource-instead-of-applying-changes
Sync Options - Argo CD - Declarative GitOps CD for Kubernetes
Sync Options Argo CD allows users to customize some aspects of how it syncs the desired state in the target cluster. Some Sync Options can defined as annotations in a specific resource. Most of the Sync Options are configured in the Application resource sp
argo-cd.readthedocs.io
- 배포가 완료되면 다음과같은 화면을 보실수있습니다. [화면이 다안나오게 찍은것은 안비밀..]
- 이제 배포된 공인ip를 확인하고 http://ip 로 접속하면 로그인 화면이 반겨줍니다.[초기 유저와 암호는 직접확인해보세요!]
- 기본제공하는 대시보드가 굉장히 많이 있네요.
- 하지만 저는 형형색색의 어그로를 끄는 대시보드를 보고싶습니다. 사람들이 구현해놓은것중에 골라서 사용해보겠습니다. 링크에서 대시보드를 검색해서 사용할수있습니다. https://grafana.com/grafana/dashboards/
Dashboards | Grafana Labs
grafana.com
- 검색에 k8s를 검색하고 조건으로 데이터소스 prometheus와 lasteupdate 순으로 나열해서 골랐습니다. [ID COPY누르기!]
- Grafana에서 좌측에서 Dashbord - Browse 누르고 우측의 import로 추가했습니다.
- 데이터 소스를 Prometheus로 지정해주면 완성입니다.
- 자세히 보니 몇몇의 패널 제목과 메트릭이 맞지않게 되있는걸보니 PromQL을 확인해서 맞게 바꿔주거나 보이지않는 패널은 PromQL을 바꿔줘야 될것같다.
다음엔 더많은 공부가 될것같다.
끝
'IT' 카테고리의 다른 글
[Helm]Subchart에 오픈소스 chart 추가하기 (0) | 2023.03.22 |
---|---|
GKE에서 ECR 이미지 사용하기 (0) | 2023.02.16 |
AWX로 앤서블 사용하기 (0) | 2023.01.30 |
ArgoCD 설치 (4) | 2023.01.16 |
AWX 설치하기 (0) | 2022.12.14 |