Container Insights 구성하기
1. 사전 준비
workernode에 필요한 IAM policy를 추가합니다.
CloudWatch가 필요한 모니터링 정보를 얻으려면 CloudWatch 에이전트를 EKS 클러스터에 설치해야 합니다. 먼저, 사용 역할 이름이 환경에 설정되어 있는지 확인해야 합니다.
test -n "$ROLE_NAME" && echo ROLE_NAME is "$ROLE_NAME" || echo ROLE_NAME is not set

만약 'ROLE_NAME is not set' 으로 확인되었다면, 실습에 사용할 사용자 역할을 환경 변수에 추가합니다.
node의 IAM Role에 policy 'CloudWatchAgentServerPolicy' 를 추가합니다.
aws iam attach-role-policy \
--role-name $ROLE_NAME \
--policy-arn arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy
IAM Role에 추가한 policy를 확인합니다.
aws iam list-attached-role-policies --role-name $ROLE_NAME | grep CloudWatchAgentServerPolicy || echo 'Policy not found'

2. Container Insights 설치하기
Container Insights를 구성하기 위해 Quick start instructions를 수행합니다.

curl -s https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/quickstart/cwagent-fluentd-quickstart.yaml | sed "s/{{cluster_name}}/eksworkshop-eksctl/;s/{{region_name}}/${AWS_REGION}/" | kubectl apply -f -
위 명령어를 수행하면 아래의 동작이 수행됩니다.
Namespace
amazon-cloudwatch 생성함.DaemonSet
에 대한 security object를 생성SecurityAccount
ClusterRole
ClusterRoleBinding
DaemonSet
으로 Cloudwatch-Agent (responsible for sending the metrics to CloudWatch)을 배포함.DaemonSet
으로 fluentd (responsible for sending the logs to Cloudwatch)을 배포함.두 DaemonSets에 대한
ConfigMap
configurations 을 배포함.

DaemonSets
가 정상적으로 배포 되었는지 확인합니다.
kubectl -n amazon-cloudwatch get daemonsets
아래 명령어를 수행하여 나온 URL을 통해 접속하여 data가 CloudWatch에 수집되고 있는지 확인합니다.
echo "
Use the URL below to access Cloudwatch Container Insights in $AWS_REGION:
https://console.aws.amazon.com/cloudwatch/home?region=${AWS_REGION}#cw:dashboard=Container;context=~(clusters~'eksworkshop-eksctl~dimensions~(~)~performanceType~'Service)"


Last updated
Was this helpful?