Loki Deployment to k8s

2023. 2. 14. 20:47·Monitoring

 

 

1. Deployment modes

https://grafana.com/docs/loki/latest/fundamentals/architecture/deployment-modes/

Loki를 배포하는 방식은 크게 3가지로 나눌 수 있습니다.

  • Monolithic mode
  • Simple scalable deployment mode
  • Microservices mode

https://grafana.com/blog/2022/12/19/the-only-helm-chart-you-need-for-grafana-loki-is-here/

위 링크의 글에 따르면, 이 세 가지 방식에 따라 helm chart도 나누어져 있습니다.

 

1.0. Deployment mode를 이해하기 위한 정보

배포 방식을 나누는 기준은, Loki의 component를 어떻게 배치시킬 것인가 입니다.

Loki의 component는 대체로 아래 5가지를 의미합니다.

  • Distributor : 데이터를 받아들이고 Ingester로 전송
  • Ingester : 데이터를 Chunk Store에 저장
  • Querier : 저장된 데이터를 조회
  • Query-Frontend : Querier 앞에서 Query를 조정하고 Query를 들고 있는 용도
  • Ruler : Query group을 지속적으로 수행 후 선언한 rule에 따라 action을 수행

 

이 5가지의 component는 각자 수행하는 역할을 기반으로 두 가지 목표(target)로 다시 나눌 수 있습니다.

  • Write : Distributor, Ingester
  • Read : Querier, Query-Frontend, Ruler

 

1.1. Monolithic mode

가장 간단한 모드입니다. -target=all 로 세팅하여 설정할 수 있습니다.

Loki의 모든 component가 하나의 process에서 작동합니다.

따라서, k8s 상에서는 하나의 pod에서 loki를 구동하며 그 안에서 모든 component 역할을 전부 수행하게 됩니다.

최소 하나의 pod만 올리면 되고, 모든 component가 하나의 process에서 구동되기 때문에 추가로 설정해줘야 하는 항목이 굉장히 적습니다.

그러므로 간단한 테스트 용도로 간편하게 구성하기 위해 사용하기에 적합합니다.

 

High availability와 Scale out

특정 component에 대한 부하만 발생하더라도 선택적으로 scale out 할 수 없습니다.

 

1.2. Simple scalable deployment mode

Loki의 component를 Write 와 Read 로 나누고, 하나의 프로세스에서 해당 그룹의 component들이 작동하도록 한 것입니다.

즉, write 의 프로세스에서는 Distributor와 Ingester의 역할을 수행하고, Read 의 프로세스에서는 Querier, Query-Frontend, Ruler의 역할을 수행합니다.

따라서, k8s 상에서는 최소 2개의 pod를 각각 -target=write, -target=read 로 지정하여 올려야 합니다.

 

High availability와 Scale out

각 target의 부하에 따라 해당 target의 pod 개수를 올리는 방식으로 적용할 수 있습니다.

예를 들어, Write에 부하가 많으면 Write pod 개수를 늘리고, Read에 부하가 많으면 Read pod 개수를 늘리면 됩니다.

 

backend 라는 target이 최근에 추가된 것으로 보입니다. storage, index, compactor 관련 component의 모임인 것 같습니다. 아직 공식 문서에는 추가된 내용이 없으나, loki의 helm chart와 module에서 확인할 수 있습니다.

https://github.com/grafana/loki/pull/7650

 

1.3. Microservices mode

Loki의 component를 각각 따로 pod로 올리는 것입니다.

 

High availability와 Scale out

각 component의 부하에 따라 pod의 개수를 올리는 방식으로 적용할 수 있습니다.

 

2. Helm charts

각 Deployment에 대해 대표적으로 사용하는 helm chart는 다음과 같습니다.

 

2.1. Monolithic mode

https://artifacthub.io/packages/helm/grafana/loki : promtail x

https://artifacthub.io/packages/helm/grafana/loki-stack : promtail o

 

2.2. Simple scalable deployment mode

https://artifacthub.io/packages/helm/grafana/loki : promtail x

https://artifacthub.io/packages/helm/grafana/loki-simple-scalable : promtail x

 

2.3. Microservices mode

https://artifacthub.io/packages/helm/grafana/loki-distributed : promtail x

 

2.4. grafana/loki chart에 대해

해당 helm chart는 monolithic mode, simple scalable deployment mode 모두 사용 가능합니다.

설정하는 방법은, _helpers.tpl 파일을 참조하면 아래와 같습니다.

{{/*
Return if deployment mode is simple scalable
*/}}
{{- define "loki.deployment.isScalable" -}}
  {{- and (eq (include "loki.isUsingObjectStorage" . ) "true") (eq (int .Values.singleBinary.replicas) 0) }}
{{- end -}}

{{/*
Return if deployment mode is single binary
*/}}
{{- define "loki.deployment.isSingleBinary" -}}
  {{- $nonZeroReplicas := gt (int .Values.singleBinary.replicas) 0 }}
  {{- or (eq (include "loki.isUsingObjectStorage" . ) "false") ($nonZeroReplicas) }}
{{- end -}}

'Monitoring' 카테고리의 다른 글

Opentelemetry - auto instrumentation  (0) 2023.08.28
Prometheus-adapter를 이용한 custom.metrics.k8s.io API 사용 (for HPA v2beta2 target)  (1) 2023.08.28
Prometheus ISSUE  (0) 2023.02.14
TSDB의 데이터 수집 방식 (polling, trapping)  (0) 2023.02.14
Prometheus Recording Rule  (0) 2023.02.14
'Monitoring' 카테고리의 다른 글
  • Opentelemetry - auto instrumentation
  • Prometheus-adapter를 이용한 custom.metrics.k8s.io API 사용 (for HPA v2beta2 target)
  • Prometheus ISSUE
  • TSDB의 데이터 수집 방식 (polling, trapping)
joeunvit
joeunvit
  • joeunvit
    joeun
    joeunvit
  • 전체
    오늘
    어제
    • 분류 전체보기 (22)
      • AWS (0)
      • Kubernetes (2)
      • IT Terminology (1)
      • Tools (1)
      • Monitoring (18)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
    • IT Terminology
    • AWS
    • Kubernetes
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    ingress-nginx #validatingwebhook
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
joeunvit
Loki Deployment to k8s
상단으로

티스토리툴바