Amazon EKS에서 Metrics Server를 사용하여 컨테이너, 포드 또는 노드의 지표를 수집할 수 없는 이유는 무엇입니까?
Amazon EKS(Amazon Elastic Kubernetes Service) 클러스터에서 Metrics Server를 사용하여 컨테이너, 포드 또는 노드의 지표를 수집할 수 없습니다.
간략한 설명
Amazon EKS에서는 Metrics Server가 기본적으로 설치되지 않습니다. 클러스터를 방금 생성했고 Metrics Server를 사용하여 컨테이너, 포드 또는 노드에서 지표를 수집할 수 없는 경우 Metrics Server 애플리케이션을 클러스터에 배포했는지 확인합니다.
Metrics Server를 사용하여 지표를 수집할 수 없는 경우 다음 섹션의 단계를 완료하세요.
- 클러스터의 노드 및 포드에서 지표를 검색할 수 있는지 확인
- APIService를 사용할 수 있고 요청을 처리할 수 있는지 확인합니다.
- GitHub에서 일반적인 문제를 확인하세요.
- 지표가 (으)로 표시되는 경우 HPA(Horizontal Pod Autoscaler) 및 애플리케이션 리소스 요청을 확인합니다.
참고: Metrics Server는 애플리케이션 및 클러스터 성능을 장기간 모니터링하기 위한 것이 아닙니다. 장기 모니터링은 컨테이너의 리소스 관리(Managing Resources for Containers)를 참조하세요.
해결 방법
클러스터의 노드 및 포드에서 지표를 검색할 수 있는지 확인
API 서버와 Metrics Server 간의 오류를 확인하려면 다음 명령을 실행하여 클러스터의 노드 및 포드에서 지표를 가져옵니다.
$ kubectl top nodes
$ kubectl top pods
두 명령에서 오류가 수신되지 않으면 APIService가 사용 중이고 요청을 처리할 수 있는지 확인 섹션의 단계를 완료합니다.
오류가 발생한 경우, 수신한 오류에 따라 다음 섹션 중 하나의 단계를 완료합니다.
- Error from server (Forbidden)(서버 오류(금지됨))
- Error from server (ServiceUnavailable)(서버 오류(서비스 사용할 수 없음))
- Client.Timeout exceeded while awaiting headers(클라이언트.헤더 대기 중에 제한 시간 초과)
- Connection refused(연결 거부됨)
Error from server (Forbidden)(서버 오류(금지됨))
이 오류 메시지는 RBAC 권한 부여에 문제가 있음을 나타냅니다. 이 오류를 해결하려면 다음을 확인하십시오.
- ServiceAccount가 배포에 올바르게 연결되어 있습니다.
- ClusterRole/Role 및 ClusterRoleBinding/RoleBindings는 Metrics Server에 대해 올바른 RBAC 권한을 사용합니다.
aws-auth ConfigMap에 정의된 역할을 통해 클러스터에 액세스하는 경우 [username(사용자 이름)] 필드 및 매핑을 설정했는지 확인합니다.
1. aws-auth ConfigMap을 설명하려면 다음 명령을 실행합니다.
$ kubectl describe -n kube-system configmap aws-auth
2. 클러스터에 액세스하는 역할에 대해 [username(사용자 이름)] 필드가 설정되었는지 확인합니다. 다음 예를 참조하세요.
Name: aws-auth Namespace: kube-system Labels: <none> Annotations: <none> Data ==== mapRoles: ---- ... - groups: - system:masters rolearn: arn:aws:iam::123456789123:role/kubernetes-devops username: devops:{{SessionName}} # Ensure this has been specified.
Error from server (ServiceUnavailable)(서버 오류(서비스 사용할 수 없음))
클러스터에서 Metrics Server 서비스 애플리케이션의 구성 문제를 확인하려면 다음 명령을 실행합니다.
$ kubectl describe apiservices v1beta1.metrics.k8s.io
출력은 다음과 유사합니다.
Name: v1beta1.metrics.k8s.io Namespace: Labels: app=metrics-server ... API Version: apiregistration.k8s.io/v1 Kind: APIService Spec: Group: metrics.k8s.io Group Priority Minimum: 100 Insecure Skip TLS Verify: true Service: Name: metrics-server Namespace: kube-system ... Status: Conditions: Last Transition Time: 2020-01-09T13:57:23Z Message: all checks passed Reason: Passed Status: True Type: Available Events: <none>
Metrics Server 서비스를 사용할 수 있고 검사를 통과하면 [Status(상태)]가 True로 설정됩니다.
[Status(상태)]가 True로 설정되어 있어도 문제가 해결되지 않으면 APIService를 사용할 수있고 요청을 처리할 수 있는지 확인 섹션의 단계를 완료합니다.
[Status(상태)]가 False로 설정된 경우 출력의 [Conditions(조건)]에 대해 연결된 [Reason(사유)]코드와 사람이 읽을 수 있는 [Message(메시지)]를 찾습니다. 실패한 APIService의 다음 예제를 참조하세요.
... Status: Conditions: Last Transition Time: 2020-01-09T14:40:28Z Message: no response from https://10.0.35.231:443: Get https://10.0.35.231:443: dial tcp 10.0.35.231:443: connect: connection refused Reason: FailedDiscoveryCheck Status: False Type: Available
[Reason(사유)]이 [FailedDiscoveryCheck]가 아닌 경우 기타 APIServer 조건 실패 사유 섹션의 단계를 완료합니다.
사유 코드가 [FailedDiscoveryCheck] 경우 Metrics Server 서비스를 사용할 수 있고 포드가 실행 중인 것입니다. Kubernetes APIServer는 Metrics Server 엔드포인트에 도달하려고 하면 오류를 반환합니다.
APIServer 조건 메시지에 "Client.Timeout exceeded while awaiting headers(클라이언트. 헤더 대기 중에 제한 시간 초과)"가 포함되어 있는 경우 "클라이언트. 헤더 대기 중에 제한 시간 초과" 오류 해결 섹션의 단계를 완료합니다.
APIServer 조건 메시지에 "connection refused(연결 거부)"가 포함되어 있는 경우 "연결 거부" 오류 해결 섹션의 단계를 완료합니다.
"Client.Timeout exceeded while awaiting headers(클라이언트. 헤더 대기 중에 제한 시간 초과)” 오류 해결
APIService에 대한 이 오류 메시지는 보안 그룹 또는 네트워크 ACL(액세스 제어 목록)이 올바르게 구성되지 않았음을 나타냅니다. 이렇게 하면 metrics-server 포드에 액세스할 수 없습니다. 다음 예를 참조하세요.
no response from https://10.0.35.231:443: Get https://10.0.35.231:443: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
이 오류를 해결하려면 보안 그룹이 Amazon EKS에 대한 최소 트래픽 요구 사항을 준수하는지 확인하세요.
"connection refused(연결 거부됨)" 오류 해결
APIServer 메시지의 이 오류는 컨테이너가 잘못된 포트에서 수신 대기하고 있음을 나타냅니다. 다음 예를 참조하세요.
no response from https://10.0.35.231:443: Get https://10.0.35.231:443: dial tcp 10.0.35.231:443: connect: connection refused
이 오류를 해결하려면 다음 명령을 실행하여 metrics-server 배포에서 포트, 이미지 및 명령의 값이 올바른지 확인합니다.
$ kubectl describe deployment metrics-server -n kube-system
출력은 다음과 유사합니다.
Name: metrics-server Namespace: kube-system CreationTimestamp: Wed, 08 Jan 2020 11:48:45 +0200 Labels: app=metrics-server ... Containers: metrics-server: Image: gcr.io/google_containers/metrics-server-amd64:v0.3.6 Port: 443/TCP Command: - /metrics-server - --logtostderr - --secure-port=443 ...
참고: 명령 및 이미지 값은 Metrics Server가 배포된 방식과 이미지가 저장된 위치에 따라 다를 수 있습니다. 명령에 --secure-port 파라미터가 포함되어 있는 경우 포드에서 노출한 포트(앞의 예제에서 443/TCP, )가 이 파라미터와 일치해야 합니다. 명령에 --secure-port 파라미터가 포함되어 있지 않으면 포트의 기본값은 443입니다.
기타 APIServer 조건 실패 사유
APIService에 대한 다음 코드 중 하나를 수신한 경우 연결된 오류 메시지인 ServiceNotFound, ServiceAccessError, ServicePortError, EndpointsNotFound, EndpointsAccessError, MissingEndpoints에 따라 조치를 취합니다.
1. 오류와 함께 서비스에 대한 정보를 가져오려면 다음 명령을 실행합니다.
$ kubectl get service -n kube-system
출력에서 Kubernetes 서비스가 APIService.Spec.Service에 정의된 이름과 네임스페이스가 동일한지 확인합니다. 그런 다음 포트가 443/TCP로 설정되어 있는지 확인합니다. 다음 예를 참조하세요.
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE metrics-server ClusterIP 172.20.172.133 <none> 443/TCP 65m
2. 엔드포인트를 나열하려면 다음 명령을 실행합니다.
$ kubectl get endpoints metrics-server -n kube-system
출력에서 metrics-server 서비스에 대한 엔드포인트가 하나 이상 있는지 확인합니다.
NAME ENDPOINTS AGE metrics-server 10.0.35.231:443 76m
3. 배포가 존재하고 레이블이 metrics-server 서비스의 레이블과 일치하는지 확인하려면 다음 명령을 실행합니다.
$ kubectl describe deploy metrics-server -n kube-system
출력에서 배포에 복제본이 하나 이상 있는지 확인합니다.
Name: metrics-server Namespace: kube-system CreationTimestamp: Wed, 08 Jan 2020 11:48:45 +0200 Labels: app=metrics-server release=metrics-server ... Selector: app=metrics-server,release=metrics-server Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable ... Pod Template: Labels: app=metrics-server release=metrics-server Service Account: metrics-server Containers: metrics-server: Image: gcr.io/google_containers/metrics-server-amd64:v0.3.6 ...
Metrics Server를 사용하여 지표를 수집할 수 없는 경우, APIService가 사용 가능하고 요청을 처리할 수 있는지 확인 섹션의 단계를 완료합니다.
APIService를 사용할 수 있고 요청을 처리할 수 있는지 확인
Metrics Server 포드에서 로그를 추출하려면 다음 명령을 실행합니다.
$ kubectl logs -n <namespace> -l app=metrics-server
예를 들어 metrics-server의 오류 로그는 E로 시작합니다.
E0610 23:13:28.247604 1 reststorage.go:98] unable to fetch pod metrics for pod default/php-apache-b5f58cc5f-nv8sz: no metrics known for pod "default/php-apache-b5f58cc5f-nv8sz" E0610 23:13:43.260069 1 reststorage.go:98] unable to fetch pod metrics for pod default/php-apache-b5f58cc5f-nv8sz: no metrics known for pod "default/php-apache-b5f58cc5f-nv8sz" E0610 23:16:13.346070 1 reststorage.go:98] unable to fetch pod metrics for pod default/php-apache-b5f58cc5f-cj67b: no metrics known for pod "default/php-apache-b5f58cc5f-cj67b" E0610 23:16:13.346087 1 reststorage.go:98] unable to fetch pod metrics for pod default/php-apache-b5f58cc5f-sqc6l: no metrics known for pod "default/php-apache-b5f58cc5f-sqc6l" E0610 23:16:13.346091 1 reststorage.go:98] unable to fetch pod metrics for pod default/php-apache-b5f58cc5f-4cpwk: no metrics known for pod "default/php-apache-b5f58cc5f-4cpwk"
Metrics Server에서 보고한 오류 로그는 Metrics Server 배포 명령의 구성 문제 또는 Metrics Server 컨테이너의 버그를 나타냅니다. 오류 메시지가 명확하지 않거나 버그라고 의심되는 경우 GitHub에서 일반적인 문제 확인 섹션의 단계를 완료합니다.
GitHub에서 일반적인 문제 확인
컨테이너, 포드 또는 노드에서 지표를 수집할 수 없는 경우 GitHub에서 Metrics Server와 관련된 일반적인 문제를 확인하세요.
알 수 없는 지표에 대해 HPA 및 애플리케이션 리소스 요청 확인
1. HPA 구성을 테스트하려면 다음 명령을 실행합니다.
$ kubectl get hpa -n namespace 2048-deployment
참고: namespace 및 2048-deployment를 애플리케이션의 HPA 구성 값으로 바꿉니다.
출력의 [대상(Targets)] 열 아래에 이(가) 표시될 수 있습니다. 다음 예를 참조하세요.
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE 2048-deployment Deployment/2048-deployment <unknown>/80% 1 2 2 10s
2. 몇 분 기다린 다음 1단계의 명령을 반복합니다.
그래도 오류가 발생하면 다음 명령을 실행합니다.
$ kubectl describe hpa -n <namespace> 2048-deployment
그리고 출력의 이벤트(Events) 섹션에서 자세한 내용을 확인합니다.
Name: 2048-deployment Namespace: 2048-game ... Metrics: ( current / target ) resource cpu on pods (as a percentage of request): <unknown> / 80% Min replicas: 1 Max replicas: 2 Deployment pods: 2 current / 2 desired Conditions: Type Status Reason Message ---- ------ ------ ------- AbleToScale True SucceededGetScale the HPA controller was able to get the target's current scale ScalingActive False FailedGetResourceMetric the HPA was unable to compute the replica count: missing request for cpu Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedGetResourceMetric 3m29s (x4333 over 19h) horizontal-pod-autoscaler missing request for cpu
메시지(Message) 열에 **[x]에 대한 요청 누락(missing request for [x])**이 표시되면 배포(Deployments) 또는 ReplicaSet의 사양에서 리소스 요청이 선언되지 않은 것일 수 있습니다. 포드의 모든 컨테이너에 선언된 요청이 있는지 확인하세요.
요청 한 개를 남기면 HPA의 지표가 응답을 반환할 수 있습니다. 자세한 내용은 컨테이너의 리소스 관리(Managing Resources for Containers)를 참조하세요.

관련 콘텐츠
- 질문됨 21일 전lg...
- 질문됨 3일 전lg...
- 질문됨 5년 전lg...
- 질문됨 23일 전lg...
- AWS 공식업데이트됨 일 년 전
- AWS 공식업데이트됨 5달 전
- AWS 공식업데이트됨 7달 전