본문 바로가기
IT Knowledge/모니터링

install Fluent Bit on Kubernetes

by Seok. 2023. 9. 6.
반응형

Kubernetes 노드 클러스터를 관리하므로, 모든 Pod 로그를 수집하려면 모든 노드에서 로그 에이전트를 실행해야 합니다.

따라서, Fluent Bit DaemonSet으로 배포 됩니다.

 

Fluent Bit 실행되면 모든 Pod 로그를 읽고 구문분석하고 필터링 하여 다음 정보로 항목을 보강합니다.

  • Pod 이름 / Pod ID / 컨테이너 이름 / 컨테이너 ID / 라벨 / 주석

설치

 

Install With Helm Chart

Fluent Bit 배포하는 권장 방법은 공식 Helm 차트를 사용하는 것입니다.

(1.9 버전부터는 helm Chart 이용하는 방법을 권장합니다. )

(https://github.com/fluent/helm-charts)

 

 

Fluent helm chart 레포지토리를 추가

 

To validate that the repo was added you can run helm search repo fluent to ensure the charts were added.

The default chart can then be installed by running the following

helm upgrade --install fluent-bit fluent/fluent-bit

 

 

Install with yaml file

(1.8 버전 이하 권장)

Github 경로 : Fluent/fluent-bit-kubernetes-logging

  • Service-account
  • Role
  • Role-binding
  • Daemon-set
  • configmap

 

Kubernetes v1.22 and above

$ kubectl create namespace logging
$ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-service-account.yaml
$ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-role-1.22.yaml
$ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-role-binding-1.22.yaml
 

 

 

 

[Daemon-Set]

[Daemon-Set] - to Elasticsearch

 
$ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/output/elasticsearch/fluent-bit-ds.yaml

[Daemon-Set] - to Kafka

 
$ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/output/kafka/fluent-bit-ds.yaml

 

 

 

[ConfigMap]

 

[ConfigMap] - to Elasticsearch

 
$ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/output/elasticsearch/fluent-bit-configmap.yaml

[ConfigMap] - to Kafka

 
$ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/output/kafka/fluent-bit-configmap.yaml

 

Fluent-bit.conf 설정

# ES의 경우      > @INCLUDE output-elasticsearch.conf

# Kafka의 경우 > @INCLUDE output-kafka.conf

 

 

Input-kubernetes.conf 설정

# 기본 ConfigMap 에서는 클러스터를 dockershim 사용했다고 가정합니다.

따라서, containerd or CRI-O 같은 CRI런타임을 사용하는 경우, CRI 파서 사용해야 합니다.

 

Cri PARSER 없으면 추가.

 

OutPut 설정

ES 설정

  output-elasticsearch.conf: |
    [OUTPUT]
        Name            es
        Match           *
        Host            ${FLUENT_ELASTICSEARCH_HOST}
        Port            ${FLUENT_ELASTICSEARCH_PORT}
        Logstash_Format On
        Replace_Dots    On
        Retry_Limit     False

 

 

Kafka 설정

  output-kafka.conf: |
    [OUTPUT]
        Name           kafka
        Match          *
        Brokers        bootstrap.kafka:9092
        Topics         ops.kube-logs-fluentbit.stream.json.001
        Timestamp_Key  @timestamp
        Retry_Limit    false
        # hides errors "Receive failed: Disconnected" when kafka kills idle connections
        rdkafka.log.connection.close false
        # producer buffer is not included in http://fluentbit.io/documentation/0.12/configuration/memory_usage.html#estimating
        rdkafka.queue.buffering.max.kbytes 10240
        # for logs you'll probably want this ot be 0 or 1, not more
        rdkafka.request.required.acks 1

Output 속성 : https://docs.fluentbit.io/manual/pipeline/outputs/kafka

 

 


 

참조 :

https://github.com/fluent/fluent-bit-kubernetes-logging

https://docs.fluentbit.io/manual/v/1.8/installation/kubernetes

https://docs.fluentbit.io/manual/pipeline/outputs/kafka

 

 

 

반응형

댓글