❤️
악분의 ArgoCD 공부기록
  • Home
  • Argo CD 소개
    • 실습자료
    • 컨셉과 장단점
    • 설치
    • 아키텍처
  • ArgoCD CLI 설치
    • 설치
    • login
  • ARGO CD HelloWorld
    • nginx pod, service 배포
  • ARGO CD 단위
    • 소개
    • Applicaiton
    • Project
  • Sync 설정
    • 소개
    • Refresh Period
    • 수동 Refresh
    • Sync와 Sync Policy
    • Sync Status
    • Health Status
    • Prune
    • Directory Recurse
    • Self healing
    • Ignore Difference
    • Non Cascade 삭제
    • ArgoCD로 관리되는지 확인
    • 기존 리소스 연결
    • helm chart
    • kustomize
  • Sync LifeCycle
    • Phases
  • private repository
    • 소개
    • git private repo 관리
  • User 관리
    • 소개
    • Argo CD user
    • Built-in user
    • Local user 생성
    • 권한(Role) 관리
  • Argo CD Project
    • Project란?
    • Project 생성 예제
    • Project 설정
    • Project 설정 예제
    • Project 권한(Role)과 예제
  • App of Apps
    • App of Apps 패턴
  • Multi cluster 관리
    • 클러스터 추가
  • 모니터링
    • 소개
    • Argo CD Metrics 추가
    • Prometheus Operator 설치
Powered by GitBook
On this page
  • 준비
  • (옵션) OpenEBS 설치
  • Promtheus Operator 설치
  • Dynamic Provisioning 설정
  • Promtheus Operator 설치
  • 설치 확인
  • serviceaccount 생성
  • 부록: Grafana 접속방법
  • 참고자료
  1. 모니터링

Prometheus Operator 설치

PreviousArgo CD Metrics 추가

Last updated 2 years ago

준비

helm이 설치되어 있어야 하고 Dynamic Provisioning 개념과 Promtheus Operator 사용방법을 알고 있어야 합니다.

(옵션) OpenEBS 설치

Dynamic Provisioning이 활성화 되어 있으면 OpenEBS는 설치하지 않아도 됩니다.

Dynamic Provisioning(동적 불륨 프로비저닝)을 사용하기 위해 OpenEBS를 설치합니다.

helm repo add openebs https://openebs.github.io/charts
helm repo update
helm install openebs --namespace openebs openebs/openebs --create-namespace

sdf정상적으로 설치되면 OpenEBS storageclass가 설치됩니다.

kubectl get sc | grep openebs

Promtheus Operator 설치

Dynamic Provisioning 설정

Persistence Volume의 Storage class를 OpenEBS hostpath를 사용하겠습니다. hostpath의 단점은 데이터가 pod가 실행한 node에만 있으므로 nodeSelector 또는 nodeAffinity를 설정해줘야 합니다. 저는 nodeAffinity를 사용했습니다.

nodeAffinity를 사용하기 위해 노드 한개를 선택하고 node=promtheus이름으로 라벨링을 합니다. 저는 node2이름을 갖는 노드를 라벨링했습니다.

kubectl label node node2 node=prometheus

Promtheus Operator 설치

helm repo를 추가합니다.

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

values.yaml파일을 생성하고 오버라이딩 할 값을 설정합니다. 데이터 저장기간(retention)과 NodeAffinity를 설정했습니다.

prometheus:
  prometheusSpec:
    # tsdb보존 기간
    retention: 10d

    # volume nodeaffinity
    storageSpec:
      volumeClaimTemplate:
        spec:
          storageClassName: openebs-hostpath
          accessModes: ["ReadWriteOnce"]
          resources:
            requests:
              storage: 50Gi

promtheus-operator 차트를 설치합니다.

helm upgrade --install \
-n promtheus-stack --create-namespace \
-f values.yaml \
operator \
prometheus-community/kube-prometheus-stack

설치 확인

pod가 전부 Running상태인지 확인합니다.

kubectl --namespace prometheus-stack get pods -l "release=operator"

serviceaccount 생성

promtheus CRD를 생성하기 위해 serviceaccount와 clusterrole, clusterrolebinding을 생성합니다. argocd가 설치된 argocd namespace에 serviceaccount를 생성했습니다.

kubectl apply -f serviceaccount_with_role.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: prometheus
  namespace: argocd
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: prometheus
rules:
- apiGroups: [""]
  resources:
  - nodes
  - nodes/metrics
  - services
  - endpoints
  - pods
  verbs: ["get", "list", "watch"]
- apiGroups: [""]
  resources:
  - configmaps
  verbs: ["get"]
- apiGroups:
  - networking.k8s.io
  resources:
  - ingresses
  verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/metrics"]
  verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: prometheus
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: prometheus
subjects:
- kind: ServiceAccount
  name: prometheus
  namespace: argocd

부록: Grafana 접속방법

Promtheus Operator stack helm차트를 설치하면 Grafana도 같이 설치됩니다.

kubectl -n promtheus-stack get deploy,svc

Grafana에 접속하기 위해 svc를 port-forward하거나 타입을 nodePort로 변경하면 됩니다. 저는 port-forward를 사용했습니다.

 kubectl -n promtheus-stack port-forward service/operator-grafana 8080:80

grafana 관리자 계정과 비밀번호는 secret으로 저장됩니다.

jsonpath로 계정과 비밀번호를 조회할 수 있습니다.

# 관리자 계정
kubectl -n promtheus-stack get secret operator-grafana -o jsonpath='{.data.admin-user}' | base64 -d; echo

# 관리자 비밀번호
kubectl -n promtheus-stack get secret operator-grafana -o jsonpath='{.data.admin-password}' | base64 -d; echo

참고자료

promtheus operator helm charts:

OpenEBS promtheus install example:

promtheus operator getting-started:

https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics
https://openebs.io/docs/stateful-applications/prometheus
https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/user-guides/getting-started.md