brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Jul 09. 2021

EKS 2탄-5. AWS EKS-클라우드와치-5/11

실습 2탄 = 5/11

<1>  EKS 클러스터 서버에  cloudwatch 에이전트  설치.




<1>  EKS 클러스터 서버에  cloudwatch 에이전트  설치.


EC2 인스턴스의 디스크 사용량과 메모리 사용량을 감시 설정

지표 수집 

https://docs.aws.amazon.com/ko_kr/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-common-scenarios.html




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 





https://console.aws.amazon.com/cloudwatch/home?region=us-west-2#cw:dashboard=Container;context=~(clusters~'eksworkshop-eksctl~dimensions~(~)~performanceType~'Service)



7

AWS 워크셥으로 공부하기~


 Container Insights  work shop

https://www.eksworkshop.com/intermediate/250_cloudwatch_container_insights/



# AWS EKS 실습 2탄

https://brunch.co.kr/@topasvga/1882



https://brunch.co.kr/@topasvga/1679


다음과정

https://brunch.co.kr/@topasvga/1697

브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari