본문 바로가기
융복합 프로젝트 PZONE

<PZONE 프로젝트> 8. EKS Cluster Autoscaling 적용하기

by 앙팡공기팡 2023. 2. 21.

 

 

지난 글

 

 

 

EKS로 Kubernetes Cluster 생성 및 ECR repository 생성 및 push하기: https://cooookieeee.tistory.com/9

 

 

 

 

 

 

 

진행사항

 

 

 

본 작업은 EKS control plane instance에서 진행되었다.

 

 

1.  Cluster Autoscaler가 IAM 역할을 사용하기 위해 필요한 권한을 부여하는 IAM 정책을 만든다.

   

    - policy.json 생성 후  aws iam create-policy  명령어를 통해 policy 생성  

 

 

2. eksctl 명령어를 통해 policy권한으로  Account에 Role을 부여해 해당 AWS resource에 작업을 가능하게 하는

    iamserviceaccount를 생성한다.(arn 저장)

 

    - eksctl create iamserviceaccount

 

 

3. Cluster -autoscaling.yaml을 apply한다.

 

    - kubectl apply -f cluster-autoscaler-autodiscover.yaml

 

 

4.  serviceaccount의 annotation에 아까 생성한 iam serviceaccount의 arn을 annotation으로 지정해 policy를 가져온다.

 

 

5.  Cluster Autoscaling의 배포를 편집한다.

 

    - kubectl -n kube-system edit deployment.apps/cluster-autoscaler 

 

 

 

 

결과

 

노드 개수 기본 2개

 

노드의 허용 pod을 넘겨보았다.
노드 수가 증가하였다.

https://youtu.be/skku0qkFp5I

 

문제점 및 개선점

 

 

1. 파드가 FailedScheduling 이벤트 메시지로 보류 중인 문제 (pod 이 자꾸 error 및 pending상태)

   

    -kubectl get events --namespace

    -kubectl describe pod YOUR_POD_NAME

    -kubectl describe deployments.apps -n kube-system cluster-autoscaler

    -kubectl logs Podname

    -명령어를 통해 이유를 분석해 보았다.

 

    -  첫번째 가설: t2 micro의 pod 개수 한계가 낮기때문이다.  : t2.micro -> t3.medium로 변경시켜주었다.

    -  두번째 가설: 쿠버네티스 버전이 낮아서 호환이 안된다: 쿠버네티스 버전을  1.22.1로 업데이트 시켜주었다.

 

 

2. Cluster 삭제시 eks delete를 써야한다. 아니면 생성된 resource를 직접 지워야하거나, 지울때 서로 충돌이 일어난다.

 

 

Ref

 

 

https://docs.aws.amazon.com/ko_kr/eks/latest/userguide/autoscaling.html

 

-eks CA 설치 aws공홈

 

https://aws.amazon.com/ko/premiumsupport/knowledge-center/eks-pod-status-troubleshooting/

 

-pod 문제 상태 해결

 

https://may9noy.tistory.com/539

 

-instance type별 배포 가능한 pod 수

 

https://anggeum.tistory.com/entry/Kubernetes-%EC%BF%A0%EB%B2%84%EB%84%A4%ED%8B%B0%EC%8A%A4-%EB%A0%88%EC%9D%B4%EB%B8%94-%EC%96%B4%EB%85%B8%ED%85%8C%EC%9D%B4%EC%85%98-Label-Annotation-Deep-Dive

 

-kubernetes label annotation