Zum Hauptinhalt springen

Thanos

Thanos는 Prometheus를 확장하여 고가용성(HA) 쿼리 레이어를 제공하는 오픈소스 프로젝트입니다. Lumie 인프라에서는 Prometheus Sidecar와 연동하여 통합 쿼리 엔드포인트를 제공합니다. Grafana는 Prometheus에 직접 연결하는 대신 Thanos Query를 통해 메트릭을 조회합니다. 현재 Sidecar는 MinIO로의 업로드 없이 쿼리 기능만 제공합니다 (로컬 저장소 전용).

배포 구성

  • 네임스페이스: thanos
  • 차트: thanos v17.3.1 (Bitnami)
  • 이미지: zot.lumie-infra.com/thanos/thanos:v0.37.2
  • 오브젝트 스토리지: MinIO (S3 호환, 시크릿 프로비저닝됨 — 현재 업로드 비활성화)

아키텍처

활성화된 컴포넌트

현재 소규모 단일 클러스터 환경이므로 쿼리 기능만 활성화되어 있습니다:

컴포넌트상태설명
Query활성화통합 쿼리 엔드포인트
Query Frontend비활성화쿼리 캐싱 레이어 (소규모 불필요)
Store Gateway비활성화MinIO에서 과거 데이터 조회
Compactor비활성화MinIO 데이터 압축 및 다운샘플링
Ruler비활성화알림 규칙 평가 (Prometheus에서 처리)
Receive비활성화Remote Write 수신 (Sidecar 방식 사용)

Thanos Query 설정

query:
enabled: true
replicaCount: 1
priorityClassName: medium-priority

# Prometheus Sidecar 자동 발견
dnsDiscovery:
enabled: true
sidecarsService: prometheus-kube-prometheus-thanos-discovery
sidecarsNamespace: prometheus

# 쿼리 최적화
extraFlags:
- --query.replica-label=prometheus_replica
- --query.auto-downsampling

resources:
requests:
cpu: 15m
memory: 100Mi
limits:
memory: 105Mi

DNS 기반 Sidecar 발견

dnsDiscovery를 통해 prometheus 네임스페이스의 Thanos Sidecar를 자동으로 발견합니다. Prometheus kube-prometheus-stack이 생성하는 prometheus-kube-prometheus-thanos-discovery 서비스를 통해 gRPC 연결이 이루어집니다.

데이터 중복 제거

Prometheus 레플리카가 여러 개인 경우 동일 메트릭이 중복 수집될 수 있습니다. Thanos Query는 prometheus_replica 라벨을 기준으로 중복을 제거합니다:

--query.replica-label=prometheus_replica

MinIO 오브젝트 스토리지 연동

현재 Store Gateway와 Compactor가 비활성화되어 MinIO 업로드는 이루어지지 않습니다. 시크릿은 향후 장기 저장 활성화를 위해 프로비저닝된 상태입니다.

시크릿 구성

MinIO 접속 정보는 Vault에서 관리하며, Vault Secrets Operator(VSO)가 Kubernetes Secret을 자동 생성합니다:

# common-values.yaml
common:
vaultStaticSecrets:
- name: minio-vss
path: infrastructure/minio
destination:
name: thanos-objstore-secret
transformation:
templates:
objstore.yml: |
type: S3
config:
bucket: thanos
endpoint: minio.minio.svc.cluster.local:9000
access_key: {{ .Secrets.MINIO_ROOT_USER }}
secret_key: {{ .Secrets.MINIO_ROOT_PASSWORD }}
insecure: true

MinIO 엔드포인트는 클러스터 내부 서비스 주소를 사용하며, 클러스터 내부 통신이므로 TLS를 사용하지 않습니다(insecure: true).

시크릿 참조

existingObjstoreSecret: thanos-objstore-secret

Bitnami 이미지 정책 우회

공식 Thanos 이미지(quay.io/thanos/thanos)를 사용하기 위해 Bitnami 이미지 정책을 비활성화합니다:

global:
security:
allowInsecureImages: true

image:
registry: zot.lumie-infra.com
repository: thanos/thanos
tag: v0.37.2

Prometheus Sidecar 연동

Thanos Sidecar는 Prometheus와 함께 실행되며, kube-prometheus-stack Helm 값에서 설정됩니다:

# prometheus/helm-values.yaml (참고)
thanos:
image: zot.lumie-infra.com/thanos/thanos:v0.37.2
# objectStorageConfig 제거 - MinIO 업로드 비활성화, 로컬 저장소만 사용

Sidecar는 현재 MinIO 업로드 없이 Thanos Query에 StoreAPI를 노출하는 쿼리 기능만 제공합니다. TSDB 블록 업로드는 Store Gateway / Compactor와 함께 필요 시 활성화 가능합니다.

메트릭 모니터링

Thanos 자체 메트릭도 Prometheus로 수집됩니다:

metrics:
enabled: true
serviceMonitor:
enabled: true
namespace: thanos
labels:
release: prometheus

엔드포인트

서비스주소용도
Thanos Queryhttp://thanos-query.thanos.svc.cluster.local:9090Grafana 데이터소스
Thanos Query gRPCthanos-query.thanos.svc.cluster.local:10901내부 gRPC 통신

문제 해결

Sidecar 연결 확인

# Thanos Query 파드 상태 확인
kubectl get pods -n thanos

# Sidecar 발견 상태 확인
kubectl port-forward -n thanos svc/thanos-query 9090:9090
# http://localhost:9090/stores 에서 연결된 Store 목록 확인

쿼리 실행 테스트

# Thanos Query를 통한 메트릭 조회
kubectl port-forward -n thanos svc/thanos-query 9090:9090
curl 'http://localhost:9090/api/v1/query?query=up'

MinIO 연결 문제

# 시크릿 생성 확인
kubectl get secret -n thanos thanos-objstore-secret

# VSO 상태 확인
kubectl get vaultstaticsecret -n thanos

# MinIO 연결 테스트
kubectl exec -n thanos deploy/thanos-query -- \
wget -qO- http://minio.minio.svc.cluster.local:9000/minio/health/live

로그 확인

# Thanos Query 로그
kubectl logs -n thanos deploy/thanos-query

# Prometheus Sidecar 로그
kubectl logs -n prometheus prometheus-kube-prometheus-prometheus-0 -c thanos-sidecar

관련 문서