티스토리 뷰

문제

Container Insights의 로그 솔루션 fluentd로 진행하다가 오류 발생. 제대로 동작하지 않음

kubectl apply -f fluentd.yaml

 

해결

공식문서에 따르면 아래와 같이 Fluentd 대신 Fluent Bit를 사용하라고 권장함

 

 

Fluent Bit를 설치하여 컨테이너에서 Logs로 로그를 전송하려면 CloudWatch

1) amazon-cloudwatch 네임스페이스 생성

kubectl apply -f <https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/cloudwatch-namespace.yaml>

 

2) 로그를 전송할 클러스터 이름 및 리전 정보가 담긴 cluster-info 를 ConfigMap 로 생성

ClusterName=cluster-name
RegionName=cluster-region
FluentBitHttpPort='2020'
FluentBitReadFromHead='Off'
[[ ${FluentBitReadFromHead} = 'On' ]] && FluentBitReadFromTail='Off'|| FluentBitReadFromTail='On'
[[ -z ${FluentBitHttpPort} ]] && FluentBitHttpServer='Off' || FluentBitHttpServer='On'
kubectl create configmap fluent-bit-cluster-info \\
--from-literal=cluster.name=${ClusterName} \\
--from-literal=http.server=${FluentBitHttpServer} \\
--from-literal=http.port=${FluentBitHttpPort} \\
--from-literal=read.head=${FluentBitReadFromHead} \\
--from-literal=read.tail=${FluentBitReadFromTail} \\
--from-literal=logs.region=${RegionName} -n amazon-cloudwatch

플러그 인 지표 모니터링을 위한 FluentBitHttpServer는 기본적으로 활성화됨

(비활성화하려면 명령의 세 번째 줄을 FluentBitHttpPort=''(빈 문자열)로 변경하면 됨)

기본적으로 Fluent Bit는 테일에서 로그 파일을 읽으며 배포된 후 새 로그만 캡처함

(FluentBitReadFromHead='On'으로 설정하면 파일 시스템의 모든 로그를 수집함)

 

3) Fluent Bit 데몬 세트를 다운로드한 후 클러스터에 배포

Fluent Bit 최적화 구성

kubectl apply -f <https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/fluent-bit/fluent-bit.yaml>

 

Fluentd와 더 유사한 Fluent Bit 구성

kubectl apply -f <https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/fluent-bit/fluent-bit-compatible.yaml>

 

4) 배포 검증. 각 노드에는 fluent-bit-로 시작하는 포드가 하나 있어야 함

kubectl get pods -n amazon-cloudwatch

 

참고자료

Amazon EKS 및 Kubernetes에서 Container Insights의 빠른 시작 설정 - Amazon CloudWatch

댓글