Load To Technical Architect

[AWS] EKS Horizontal Pod Autoscaler ( HPA ) 구성 방법 본문

Cloud/AWS

[AWS] EKS Horizontal Pod Autoscaler ( HPA ) 구성 방법

고지식한청춘 2021. 11. 18. 17:05
728x90

AWS EKS (Elastic Kubernetes Service)에서 Horizontal Pod Autoscaler (HPA)를 활용한 Pod AutoScaling 구성하는 방법

 

AWS EKS Document : https://docs.aws.amazon.com/eks/latest/userguide/horizontal-pod-autoscaler.html

 

 

[ 사전 준비 ]

- EKS Cluster에 접속 할 환경에 kubectl, git 설치

- 최소 하나 이상의 deployment가 cluster에 배포되어있어야 함

- deployment에 리소스(CPU) 사용량이 아래의 예시와 같이 정해져있어야 함

resources:
  requests:
    cpu: "500m"

 

 

[ CLI 작업 ]

1. hpa ( metric-server ) 배포

$ kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

2. hpa 적용

$ kubectl autoscale deployment -n <namespace> <deployment name> --min <최소 pod 수> --max <최대 pod 수 > --cpu-percent=<autoscaling trigger cpu usage>
ex) $ kubectl autoscale deployment -n test test-deployment --min 1 --max 2 --cpu-percent=20

3. 적용된 hpa 확인

$ kubectl get hpa -n <namespace> -w

4. hpa 수정

$ kubectl edit hpa -n <namepsace> <deployment name>

 

728x90
Comments