환경구성

EKS 1.28

기존에 설치 되어 있는 Prometheus : https://tistory-cloud.tistory.com/59


작업 내용

 

1. prometheus-operator-crd 설치

2. kube-prometheus-stack 설치

 


상세 작업 내용

 

 

1. prometheus-operator-crd 설치

  • Thanos 사용을 위한 prometheus-operator 설치
#chart : prometheus-operator-crds
git clone https://github.com/prometheus-community/helm-charts

경로 : helm-charts/charts/prometheus-operator-crds

helm install -f prometheus-operator-crds values.yaml ./

 

2. kube-prometheus-stack 설치

#chart: kube-prometheus-stack
git clone https://github.com/prometheus-community/helm-charts
경로 : helm-charts/charts/kube-prometheus-stack

 

  • chart.yaml 에서 dependencies 수정
#Chart.yaml 에서 아래와 같이 dependencies 를 주석처리
#
dependencies:
  #  - name: crds
  #  version: "0.0.0"
  #  condition: crds.enabled
      #  - name: kube-state-metrics
      #version: "5.14.*"
      #repository: https://prometheus-community.github.io/helm-charts
      #condition: kubeStateMetrics.enabled
      #  - name: prometheus-node-exporter
      #version: "4.23.*"
      #repository: https://prometheus-community.github.io/helm-charts
      #condition: nodeExporter.enabled
      #  - name: grafana
      #version: "6.60.*"
      #repository: https://grafana.github.io/helm-charts
      #condition: grafana.enabled
      #- name: prometheus-windows-exporter
      #repository: https://prometheus-community.github.io/helm-charts
      #version: "0.1.*"
      #condition: windowsMonitoring.enabled
helm dependency update

 

 

Thanos

Thanos - Highly available Prometheus setup with long term storage capabilities

thanos.io

objstore.yaml 생성

수정내용
	buket <버켓명>
	endpoint <s3.ap-northeast-2.amazonaws.com>
	region <ap-northeast-2>
	access_key <key>
	secret_key <key>
    
--------------------------------------

type: S3
config:
  bucket: ""
  endpoint: ""
  region: ""
  aws_sdk_auth: false
  access_key: ""
  insecure: false
  signature_version2: false
  secret_key: ""
  session_token: ""
  put_user_metadata: {}
  http_config:
    idle_conn_timeout: 1m30s
    response_header_timeout: 2m
    insecure_skip_verify: false
    tls_handshake_timeout: 10s
    expect_continue_timeout: 1s
    max_idle_conns: 100
    max_idle_conns_per_host: 100
    max_conns_per_host: 0
    tls_config:
      ca_file: ""
      cert_file: ""
      key_file: ""
      server_name: ""
      insecure_skip_verify: false
    disable_compression: false
  trace:
    enable: false
  list_objects_version: ""
  bucket_lookup_type: auto
  part_size: 67108864
  sse_config:
    type: ""
    kms_key_id: ""
    kms_encryption_context: {}
    encryption_key: ""
  sts_endpoint: ""
prefix: ""

 

  • 시크릿 생성
kubectl create secret generic objstore-secret \
  --from-file=objstore.yaml \
  --namespace default
  • values.yaml 수정
사용하지않는 컴포넌트 미사용으로 설정
사용하는경우 개인적으로 수정해서 사용하면 됨

EX)
		#239 alertmanager false
		#900 grafana false
		#1866 kubestatemetrics false
        
        3442 thanos secret setting <아래 사진참고>

 

  • helm install
helm install kube-prometheus-stack -f values.yaml ./

 

 

 

※참고자료

Prometheus Install : https://tistory-cloud.tistory.com/59

Prometheus Operater : https://tistory-cloud.tistory.com/60

Prometheus Thanos 연동 : https://tistory-cloud.tistory.com/61


 

Grafana 를 helm chart 를 사용하여 설치하면 편리하게 배포할 수 있다

 


 

helm chart 를 사용하여 Grafana 설치를 진행 하겠습니다.

 

1. Grafana 를 설치/사용할 namespace 를 먼저 생성

    → monitoring 이아닌 다른 namespace 도 사용 가능하다 default 로 monitoring 을 주로 사용

kubectl create ns monitoring

 

 

2. Grafana 를 다운받아올 helm repo를 추가 

    → Grafana 공식 github를 사용 

helm repo add grafana https://grafana.github.io/helm-charts

 

 

3. 추가한 repo 의 chart 를 다운로드 

helm pull grafana https://grafana.github.io/helm-charts

 

 

4. 다운로드된 chart 압축해제

tar -xvf grafana-6.60.1.tgz

 

 

 

5. grafana 폴더 안의 value.yaml 파일 수정

######## 접속을 위한 nodeport 로 변경
 185 service:
 186   enabled: true
 187   type: NodePort
 188   port: 8080
 189   targetPort: 3000
 190     # targetPort: 4181 To be used with a proxy extraContainer
 191   ## Service annotations. Can be templated.
 192   annotations: {}
 193   labels: {}
 194   portName: service
 195   # Adds the appProtocol field to the service. This allows to work with istio protocol selection. Ex: "http" or "tcp"
 196   appProtocol: ""
 197

######### admin 계정 설정 부분
 387 # Administrator credentials when not using an existing secret (see below)
 388 adminUser: admin
 389 adminPassword: admin

########## persistence 부분인데 지속적으로 grafana 를 사용할 거라면 pvc 를 사용으로 변경
 325 persistence:
 326   type: pvc
 327   enabled: false
 328   storageClassName: default
 329   accessModes:
 330     - ReadWriteOnce
 331   size: 10Gi
 332   # annotations: {}
 333   finalizers:
 334     - kubernetes.io/pvc-protection

 

 

6. helm chart 배포 

helm install grafana -f values.yaml -n monitoring ./

 

 

 

7. Grafana 접속

    → 초기 ID : admin

    → 초기 PW : 아래 있는 코드블록 내용으로 확인

kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
#접속주소 => 'NodeIP:Port'
#위 사진에 있는 ClusterIP는 Cluster 내부의 IP이기 때문에 local desktop 에서 접속시에는 사용불가
#따라서 Grafana 를 설치한 Cluster Node 의 IP 및 위 사진에 있는 Port 정보로 로그인 해야함
#ex) http://10.0.2.10:32583

 

※ 주의사항

위 Grafana 는 helm chart 를 사용해서 기본 설정으로 배포한 것으로 사용 목적에 맞게 세부사항을 수정할 수 있습니다.

대표적으로 설정할 부분은 아래와 같습니다.

 

1. PVC 사용으로 설정하여 Grafana 의 데이터 유지

2. RDS를 연동하여 사용 가능

3. SSL 설정 가능

4. NodePort 뿐아니라 LB 를 사용하여 운영 가능

kubectl get cm/grafana -n monitoring
# configmap 에서 여러 내용을 수정 할 수 있으며 자세한 내용은 grafana 공식 홈피에지에 상세하게 적혀 있습니다.

 

 

 

 

 

 

+ Recent posts