실습 2탄 = 5/11
EC2 인스턴스의 디스크 사용량과 메모리 사용량을 감시 설정
지표 수집
cwagent-fluentd 설치
1
EKS 클러스터 서버에 cloudwatch 에이전트 설치한다.
# 콘솔
# 클라우드 와치 에이전트가 노드 인스턴스에 권한이 있어야 한다. role을 사용한다. 정책을 role에 연결.
# IAM > roles 에서 nodegroup-node-gr-NodeinstanceRole 이름 확인
# Role 이름을 입력하자.
ROLE_NAME=eksctl-eks-demo2-nodegroup-node-gr-NodeInstanceRole-qt4CtJOWOeiA
echo $ROLE_NAME
역할 확인
test -n "$ROLE_NAME" && echo ROLE_NAME is "$ROLE_NAME" || echo ROLE_NAME is not set
2
role에 정책 연결?
aws iam attach-role-policy --role-name $ROLE_NAME --policy-arn arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy
3
정책 연결 확인?
aws iam list-attached-role-policies --role-name $ROLE_NAME | grep CloudWatchAgentServerPolicy || echo 'Policy not found'
"PolicyName": "CloudWatchAgentServerPolicy",
"PolicyArn": "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
4
cloudwatch insight 설치?
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 created
serviceaccount/cloudwatch-agent created
clusterrole.rbac.authorization.k8s.io/cloudwatch-agent-role created
clusterrolebinding.rbac.authorization.k8s.io/cloudwatch-agent-role-binding created
configmap/cwagentconfig created
daemonset.apps/cloudwatch-agent created
configmap/cluster-info created
serviceaccount/fluentd created
clusterrole.rbac.authorization.k8s.io/fluentd-role created
clusterrolebinding.rbac.authorization.k8s.io/fluentd-role-binding created
configmap/fluentd-config created
daemonset.apps/fluentd-cloudwatch created
5
데몬셋 배포 확인?
kubens amazon-cloudwatch
watch -d kubectl get ns,deploy,rs,svc,pods
kubectl -n amazon-cloudwatch get daemonsets
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
cloudwatch-agent 3 3 3 3 3 <none> 34s
fluentd-cloudwatch 3 3 3 3 3 <none> 34s
6
콘솔 접속
Cloudwatch > Insights > Container Insights > Add to dashboard
7
AWS 워크셥으로 공부하기~
Container Insights work shop
https://www.eksworkshop.com/intermediate/250_cloudwatch_container_insights/
https://brunch.co.kr/@topasvga/1882
https://brunch.co.kr/@topasvga/1679