Load To Technical Architect

[AWS] EKS 리소스 사용량을 Cloudwatch Container Insights에서 모니터링 하는 방법 본문

Cloud/AWS

[AWS] EKS 리소스 사용량을 Cloudwatch Container Insights에서 모니터링 하는 방법

고지식한청춘 2021. 11. 18. 17:44
728x90

[ 사전 준비 ]

- https://github.com/aws-samples/amazon-cloudwatch-container-insights/tree/master/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/cwagent

- Github에서 yaml 파일 3개 모두 서버에 저장

※중요※ Nodegroup에 한함, daemonSet의 경우 fargate는 적용 방법이 다름

 

 

[ CLI 작업 ]

1. amazon-cloudwatch namespace 생성

$ kubectl create namespace amazon-cloudwatch

2. cwagent-configmap.yaml 수정

vi cwagent-configmap.yaml

# create configmap for cwagent config
apiVersion: v1
data:
  # Configuration is in Json format. No matter what configure change you make,
  # please keep the Json blob valid.
  cwagentconfig.json: |
    {
        "agent": {
            "region": "<region-code>"
        },
        "logs": {
            "metrics_collected": {
                "kubernetes": {
                    "cluster_name": "<cluster-name>",
                    "metrics_collection_interval": 60
                }
            },
            "force_flush_interval": 5,
            "endpoint_override": "logs.<region-code>.amazonaws.com"
        },
        "metrics": {
            "metrics_collected": {
                "statsd": {
                    "service_address": ":8125"
                }
            }
        }
    }
kind: ConfigMap
metadata:
  name: cwagentconfig
  namespace: amazon-cloudwatch

 

3. yaml 파일 모두 배포

$ kubectl apply -f cwagent-configmap.yaml

$ kubectl apply -f cwagent-serviceaccount.yaml

$ kubectl apply -f cwagent-daemonset.yaml

 

4. AWS Console > Cloudwatch > Container Insights에서 리소스 사용량 확인

728x90
Comments