Get Hands-on with Amazon EKS - Workshop Event Series
Whether you're taking your first steps with Kubernetes or you're an experienced practitioner looking to sharpen your skills, our Amazon EKS workshop series delivers practical, real-world experience that moves you forward. Learn directly from AWS solutions architects and EKS specialists through hands-on sessions designed to build your confidence with Kubernetes. Register now and start building with Amazon EKS!
Amazon EKS 클러스터에서 Container Insights 지표를 켜려면 어떻게 해야 하나요?
내 Amazon Elastic Kubernetes Service(Amazon EKS) 클러스터 지표를 볼 수 있도록 Amazon CloudWatch Container Insights를 구성하고 싶습니다.
해결 방법
Container Insights는 Linux 인스턴스에서만 지원됩니다. Amazon은 Amazon Elastic Container Registry(Amazon ECR)에서 CloudWatch 에이전트 컨테이너 이미지를 제공합니다. 자세한 내용은 cloudwatch-agent/cloudwatch-agent를 참조하십시오.
시작하기 전에 CloudWatch의 Container Insights 사전 요구 사항을 충족하는지 확인하십시오. AWS Fargate 클러스터의 경우 포드를 예약하려면 Fargate 프로필을 정의해야 합니다. 또한 Amazon EKS 포드 Identity and Access Management(IAM) 역할이 Fargate 인프라에서 실행되는 구성 요소가 AWS API를 호출할 수 있도록 허용해야 합니다. 예를 들어 IAM 역할은 Amazon ECR에서 컨테이너 이미지를 가져올 수 있어야 합니다.
CloudWatch 에이전트를 사용하여 EKS 클러스터에서 Container Insights 지표 설정
CloudWatch 에이전트는 먼저 aws/containerinsights/Cluster_Name/performance라는 이름의 로그 그룹을 생성한 다음 해당 로그 그룹에 성능 로그 이벤트를 전송합니다. 지표를 수집하도록 Container Insights를 설정하는 경우 CloudWatch 에이전트 컨테이너 이미지를 도커 허브에서 DaemonSet으로 배포해야 합니다. 기본적으로 익명 사용자로 컨테이너 이미지를 배포합니다.
참고: Docker는 가져올 수 있는 이미지 수를 제한할 수 있습니다.
CloudWatch 에이전트를 사용하여 Container Insights를 설정하려면 다음 단계를 완료합니다.
-
다음 명령을 실행하여 amazon-cloudwatch 네임스페이스를 생성합니다.
kubectl apply -f https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/cloudwatch-namespace.yaml -
다음 명령을 실행하여 cloudwatch-agent라는 이름의 CloudWatch 에이전트에 대한 서비스 계정을 생성합니다.
kubectl apply -f https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/cwagent/cwagent-serviceaccount.yaml -
다음 명령을 실행하여 CloudWatch 에이전트의 구성 파일로 configmap을 생성합니다.
ClusterName= my-cluster-name curl https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/cwagent/cwagent-configmap.yaml | sed 's/cluster_name/'${ClusterName}'/' | kubectl apply -f -참고: my-cluster-name을 EKS 클러스터의 이름으로 바꾸십시오. 자세한 내용은 CloudWatch 에이전트에 대한 ConfigMap 생성을 참조하십시오.
-
다음 명령을 실행하여 cloudwatch-agent DaemonSet을 배포합니다.
kubectl apply -f https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/cwagent/cwagent-daemonset.yaml -
(선택 사항) 다음 명령을 실행하여 ECR에서 CloudWatch 에이전트를 가져오도록 cloudwatch-agent DaemonSet을 패치합니다.
kubectl patch ds cloudwatch-agent -n amazon-cloudwatch -p \ '{"spec":{"template":{"spec":{"containers":[{"name":"cloudwatch-agent","image":"public.ecr.aws/cloudwatch-agent/cloudwatch-agent:latest"}]}}}}'참고: ECR의 Cloudwatch 에이전트 도커 이미지는 ARM 및 AMD64 아키텍처를 지원합니다. 이미지 버전 및 아키텍처에 따라 최신 이미지 태그를 변경하십시오. 자세한 내용은 cloudwatch-agent/cloudwatch-agent를 참조하십시오.
-
서비스 계정에 대한 IAM 역할으로 OIDC 공급자와 IAM 역할 및 정책을 생성합니다. 다음 명령을 실행하여 IAM 역할을 cloudwatch-agent 서비스 계정에 연결합니다.
kubectl annotate serviceaccounts cloudwatch-agent -n amazon-cloudwatch "eks.amazonaws.com/role-arn=arn:aws:iam::ACCOUNT_ID:role/IAM_ROLE_NAME"참고: ACCOUNT_ID를 계정 ID로, IAM\ _ROLE\ _NAME을 서비스 계정에 사용하는 IAM 역할로 바꾸세요.
CloudWatch 에이전트 문제 해결
다음 단계를 완료합니다.
-
다음 명령을 실행하여 포드 목록을 검색합니다.
kubectl get pods -n amazon-cloudwatch -
다음 명령을 실행하여 출력 하단에서 이벤트를 확인합니다.
kubectl describe pod pod-name -n amazon-cloudwatch -
다음 명령을 실행하여 로그를 확인합니다.
kubectl logs pod-name -n amazon-cloudwatch -
CloudWatch 에이전트에서 CrashLoopBackoff 오류가 표시되면 IAM 권한을 올바르게 구성했는지 확인하십시오.
CloudWatch 에이전트 삭제
다음 명령을 실행하여 CloudWatch 에이전트를 삭제합니다.
kubectl delete -f https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/cloudwatch-namespace.yaml
참고: 네임스페이스를 삭제하면 연결된 리소스도 삭제됩니다.
Distro for OpentTelemetry를 사용하여 EKS 클러스터에서 Container Insights 지표 설정
AWS Distro for OpenTelemetry는 먼저 aws/containerinsights/Cluster_Name/performance라는 이름의 로그 그룹을 생성한 다음 해당 로그 그룹에 성능 로그 이벤트를 전송합니다.
다음 단계를 완료합니다.
-
다음 명령을 실행하여 AWS OpenTelemetry Collector를 DaemonSet으로 배포합니다.
curl https://raw.githubusercontent.com/aws-observability/aws-otel-collector/main/deployment-template/eks/otel-container-insights-infra.yaml | kubectl apply -f -참고: 자세한 내용은 Container Insights EKS 인프라 지표를 참조하십시오.
-
다음 명령을 실행하여 Collector가 실행 중인지 확인합니다.
kubectl get pods -l name=aws-otel-eks-ci -n aws-otel-eks -
(선택 사항) 다음 명령을 실행하여 aws-otel-eks-ci DaemonSet을 패치하여 ECR에서 aws-otel-collector 도커 이미지를 가져오도록 합니다.
kubectl patch ds aws-otel-eks-ci -n aws-otel-eks -p \'{"spec":{"template":{"spec":{"containers":[{"name":"aws-otel-collector","image":"public.ecr.aws/aws-observability/aws-otel-collector:latest"}]}}}}'참고: ECR의 Cloudwatch-agent 도커 이미지는 ARM 및 AMD64 아키텍처를 지원합니다. 이미지 버전 및 아키텍처에 따라 최신 이미지 태그를 변경하십시오.
-
(선택 사항) 서비스 계정에 대한 IAM 역할의 경우 OIDC 공급자와 IAM 역할 및 정책을 생성합니다. 다음 명령을 실행하여 IAM 역할을 aws-otel-sa 서비스 계정에 연결합니다.
kubectl annotate serviceaccounts aws-otel-sa -n aws-otel-eks "eks.amazonaws.com/role-arn=arn:aws:iam::ACCOUNT_ID:role/IAM_ROLE_NAME"참고: ACCOUNT_ID를 계정 ID로, IAM\ _ROLE\ _NAME을 서비스 계정에 사용하는 IAM 역할로 바꾸십시오.
Distro for OpenTelemetry 삭제
다음 명령을 실행하여 Distro for OpenTelemetry를 삭제합니다.
curl https://raw.githubusercontent.com/aws-observability/aws-otel-collector/main/deployment-template/eks/otel-container-insights-infra.yaml |kubectl delete -f -
Distro for OpenTelemetry를 사용하여 EKS Fargate 클러스터에서 Container Insights 지표 설정
EKS 및 Fargate에서 실행되는 애플리케이션의 경우 Distro for OpenTelemetry를 사용하여 Container Insights를 설정할 수 있습니다.
AWS OpenTelemetry Collector는 EKS Fargate에서 실행되는 모든 워크로드에 대해 다음과 같은 지표를 CloudWatch로 전송합니다.
- pod_cpu_utilization_over_pod_limit
- pod_cpu_usage_total
- pod_cpu_limit
- pod_memory_utilization_over_pod_limit
- pod_memory_working_set
- pod_memory_limit
- pod_network_rx_bytes
- pod_network_tx_bytes
AWS OpenTelemetry Collector는 ContainerInsights라는 CloudWatch 네임스페이스에서 각 지표를 수집합니다. CloudWatch 콘솔에서 지표를 선택한 다음 모든 지표를 선택합니다. 사용자 지정 네임스페이스에서 ContainerInsights로 이동할 수 있습니다.
각 지표는 다음 차원 세트와 연결됩니다.
- ClusterName, LaunchType
- ClusterName, Namespace, LaunchType
- ClusterName, Namespace, PodName, LaunchType
자세한 내용은 Container Insights EKS Fargate를 참조하십시오
Distro for OpenTelemetry를 EKS Fargate에 배포하려면 다음 단계를 완료합니다.
-
이름이 fargate-container-insights인 네임스페이스를 생성합니다.
-
다음 스크립트를 사용하여 이름이 adot-collector인 Kubernetes 서비스 계정과 연결된 IAM 역할 EKS-ADOT-ServiceAccount-Role을 생성합니다. 다음 도우미 스크립트에는 eksctl이 필요합니다.
#!/bin/bashCLUSTER_NAME=YOUR-EKS-CLUSTER-NAMEREGION=YOUR-EKS-CLUSTER-REGION SERVICE_ACCOUNT_NAMESPACE=fargate-container-insights SERVICE_ACCOUNT_NAME=adot-collector SERVICE_ACCOUNT_IAM_ROLE=EKS-Fargate-ADOT-ServiceAccount-Role SERVICE_ACCOUNT_IAM_POLICY=arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy kubectl create ns fargate-container-insights eksctl utils associate-iam-oidc-provider \ --cluster=$CLUSTER_NAME \ --approve eksctl create iamserviceaccount \ --cluster=$CLUSTER_NAME \ --region=$REGION \ --name=$SERVICE_ACCOUNT_NAME \ --namespace=$SERVICE_ACCOUNT_NAMESPACE \ --role-name=$SERVICE_ACCOUNT_IAM_ROLE \ --attach-policy-arn=$SERVICE_ACCOUNT_IAM_POLICY \ --approve참고: CLUSTER_NAME을 클러스터 이름으로 바꾸고 REGION을 AWS 리전으로 바꾸세요.
-
다음 명령을 실행하여 AWS OpenTelemetry Collector를 Kubernetes StatefulSet으로 배포합니다.
ClusterName= your-cluster-name Region= your-cluster-region curl https://raw.githubusercontent.com/aws-observability/aws-otel-collector/main/deployment-template/eks/otel-fargate-container-insights.yaml | sed 's/YOUR-EKS-CLUSTER-NAME/'${ClusterName}'/;s/us-east-1/'${Region}'/' | kubectl apply -f -참고: your-cluster-name을 클러스터 이름으로, your-cluster-region을 클러스터가 위치한 리전으로 바꾸십시오. Fargate에서 StatefulSet 포드를 프로비저닝하려면 일치하는 Fargate 프로필이 있는지 확인하십시오.
-
다음 명령을 실행하여 Disto for Open Telemetry Collector 포드가 실행 중인지 확인합니다.
kubectl get pods -n fargate-container-insights -
(선택 사항) 다음 명령을 실행하여 aws-otel-collector 도커 이미지를 가져오도록 adot-collector StatefulSet을 패치합니다.
kubectl patch sts adot-collector -n fargate-container-insights -p \'{"spec":{"template":{"spec":{"containers":[{"name":"adot-collector","image":"public.ecr.aws/aws-observability/aws-otel-collector:latest"}]}}}}'
Distro for OpenTelemetry 삭제
다음 명령을 실행하여 Distro for OpenTelemetry를 삭제합니다.
eksctl delete iamserviceaccount --cluster CLUSTER_NAME --name adot-collector ClusterName= your-cluster-name Region= your-cluster-region curl https://raw.githubusercontent.com/aws-observability/aws-otel-collector/main/deployment-template/eks/otel-fargate-container-insights.yaml | sed 's/YOUR-EKS-CLUSTER-NAME/'${ClusterName}'/;s/us-east-1/'${Region}'/' | kubectl delete -f -
참고: your-cluster-name을 클러스터 이름으로, your-cluster-region을 클러스터가 위치한 리전으로 바꾸십시오.
- 언어
- 한국어

관련 콘텐츠
AWS 공식업데이트됨 2년 전