[AWS] EKS cluster-autoscaler Tip

김지환·2022년 10월 17일
1

AWS EKS ( Amazon Elastic Kubernetes Service )

AWS EKS 를 사용하면서 Node scaling 에 Kubneretes cluster autoscaler 를 사용한다.

From 0 node scale

사용을 하다가 node group을 사용할 때 필요에 따라서 사용을 하지 않을 때 모든 node를 down 시킬 수 있도록 min scale 을 0 으로 설정을 했을 때 auto scale이 제대로 진행되지 않는 문제가 있었다.

원래라면 새로운 Pod가 생겼을 때 node를 새로 띄워주어야하는데, node affinity 에러가 발생하면서 node 생성이 되지 않았다.

공식문서를 찾아보니 원인은 다음과 같았다.

node 가 기존에 존재할 때는 존재하는 node instance 를 토대로 node를 scaling 하게 되는데, 만약 node 가 존재하지 않는다면 cluster autoscaler 에서는 해당 nodegroup 의 Auto scaler group (ASG) 에 등록되어 있는 launch template을 기반으로 instance를 만들게 된다.

이 부분에서 문제가 생긴것인데 내가 원했던 Pod 에는 nodeaffinity가 설정되어 있었는데 여기서 custom label을 사용했었기 때문에 launch template 에서는 이를 인식할 수 가 없고 AWS 에서 default로 만들어둔 label들만 적용되게 된다.

따라서 올바른 node를 띄울 수 없다는 에러가 나온 것이다.
이에 AWS 에서는 ASG 에 Tag 를 추가하여서 이 문제를 해결하라고 가이드를 준다.

ASG 태그에 다음과 같이 resource, label, taint 정보를 적어주면 Node scale 시 아래 정보도 같이 찾게 된다.

Key: k8s.io/cluster-autoscaler/node-template/resources/$RESOURCE_NAME
Value: 5
Key: k8s.io/cluster-autoscaler/node-template/label/$LABEL_KEY
Value: $LABEL_VALUE
Key: k8s.io/cluster-autoscaler/node-template/taint/$TAINT_KEY
Value: NoSchedule

Reference

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

profile
Developer

0개의 댓글