본문 바로가기

AWS

[AWS] EKS - Cluster Autoscaler 설정

  • EKS의 worker node 는 EC2 instacne이며 아무리 작은 크기의 pod 라고 해도 무한정으로 pod를 배포 시킬 수 없음
    • 여러개의 pod 가 만들어지면 node 가 가득 차버려서 나머지 pod 들은 pending 상태가 되어 버림
    • 이러한 문제를 해결하기 위해서 사용하는 것이 Cluster Autoscaler (CA)
  • Cluster Autoscaler (CA) 이란?
    • node의 자원이 부족하여 pod 가 pending 될 때 node의 수를 늘려주는 것
  • Cluster Autoscaler 로직
    • node의 자원이 부족하여 pending 상태가 된 pod 가 있는지 확인
    • CA가 desired capacity의 갯수를 바꿈
    • AWS 가 새로운 EC2를 생성하며 이에 해당하는 EC2가 새로운 worker node
      • 시간이 꽤 많이 소요 됨
    • pending 상태의 pod 들이 새로운 worker node에 스케줄링 됨

 

 

CA 설정

  • Cluster AutoScaling Yaml 파일 다운로드
curl -o cluster-autoscaler-autodiscover.yaml https://raw.githubusercontent.com/kubernetes/autoscaler/master/cluster-autoscaler/cloudprovider/aws/examples/cluster-autoscaler-autodiscover.yaml
  • 다운 받은 Cluster Autoscaler Yaml 파일 편집 및 적용
파일 편집기를 통해 your-cluster-name 이라고 적힌 부분 수정
- --node-group-auto-discovery=asg:tag=k8s.io/cluster-autoscaler/enabled,k8s.io/cluster-autoscaler/<your-cluster-name>

command:
- ./cluster-autoscaler
- --v=4
- --stderrthreshold=info
- --cloud-provider=aws
- --skip-nodes-with-local-storage=false
- --expander=least-waste
- --node-group-auto-discovery=asg:tag=k8s.io/cluster-autoscaler/enabled,k8s.io/cluster-autoscaler/ydy-eks-cluster

파일 적용
kubectl apply -f cluster-autoscaler-autodiscover.yaml