[EKS] Cloudwatch Container Insight 설정

이정훈·2023년 7월 10일
0

EKS

목록 보기
7/9
post-thumbnail
  • 로그 수집은 Cloudwatch agent, 전송은 Fluent Bit이 담당하는 구조로 구성

  • Fluent Bit은 DaemonSet 형태로 설치한다

1. Nodegroup Role에 권한 추가

  • Nodegroup에 Cloudwatch 로그 그룹을 생성하고 로그를 보낼 수 있는 권한을 설정
    - IAM 메뉴에서 역할 → Nodegroup에 적용된 역할 찾기
    - 역할에 CloudWatchLogsFullAccess 권한 추가

2. NameSpace 생성

- Cloudwatch agent, Fluent Bit 설치할 NS 생성
kubectl create ns amazon-cloudwatch
  • Cloudwatch agent, Fluent Bit 설치를 위한 환경 변수를 등록
# 한 줄씩 복사 & 붙여넣기
# 클러스터 이름 입력
ClusterName=MyCluster
# 리전 이름 입력
RegionName=YOUR_REGION
        
FluentBitHttpPort='2020'
FluentBitReadFromHead='Off'
[[ ${FluentBitReadFromHead} = 'On' ]] && FluentBitReadFromTail='Off'|| FluentBitReadFromTail='On'
[[ -z ${FluentBitHttpPort} ]] && FluentBitHttpServer='Off' || FluentBitHttpServer='On'

3. 설치

  • yaml 파일 다운로드
wget https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/quickstart/cwagent-fluent-bit-quickstart.yaml
  • 환경 변수 적용
sed -i 's/{{cluster_name}}/'${ClusterName}'/;s/{{region_name}}/'${RegionName}'/;s/{{http_server_toggle}}/"'${FluentBitHttpServer}'"/;s/{{http_server_port}}/"'${FluentBitHttpPort}'"/;s/{{read_from_head}}/"'${FluentBitReadFromHead}'"/;s/{{read_from_tail}}/"'${FluentBitReadFromTail}'"/' cwagent-fluent-bit-quickstart.yaml
  • 파일 적용
kubectl apply -f cwagent-fluent-bit-quickstart.yaml
  • 확인
# 생성된 파드 확인
kubectl get po -n amazon-cloudwatch
# 데몬셋 확인
kubectl get daemonsets -n amazon-cloudwatch
  • 💡 CloudWatch 실제 반영까지는 지표를 수집해야 하기 때문에 5분 정도 시간이 소요될 수 있다

profile
싱숭생숭늉

0개의 댓글