AWS/AWS_EKS

EKS HPA (동적 크기 조절)

KK_Ryong 2025. 5. 29. 11:16

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: test-nginx-hpa
  namespace: default
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: test-nginx
  minReplicas: 2
  maxReplicas: 3
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50  # CPU 사용률 70% 초과 시 확장
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageUtilization: 60  # 메모리 사용률 70% 초과 시 확장
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 60      # 기본 축소 대기 시간 300초(5분)
      policies:
        - type: Percent
          value: 50                        # 한 번에 최대 50% 축소 가능
          periodSeconds: 60                # 60초 간격으로 축소 정책 적용

-------------------------------------------------------------------------------------
asg 증설 축소 시간 조절 (설치 시 지정 안했으면 해줄 것)
kubectl edit deployment cluster-autoscaler-aws-cluster-autoscaler -n kube-system
아래 delay 부분 추가 및 수정 하기 

    spec:
      containers:
      - command:
        - ./cluster-autoscaler
        - --cloud-provider=aws
        - --namespace=kube-system
        - --nodes=2:5:dev-sw-eks-asg
        - --logtostderr=true
        - --scale-down-delay-after-add=1m      #노드 추가 후 축소를 시작하기 전 대기 시간
        - --scale-down-delay-after-delete=30s   #노드 삭제 후 다음 축소 시도까지 대기 시간 
        - --scale-down-delay-after-failure=2m   #축소 실패 후 다음 시도까지 대기 시간
        - --stderrthreshold=info
        - --v=4

'AWS > AWS_EKS' 카테고리의 다른 글

EKS ingress 추가(argocd)  (0) 2025.06.04
EKS Jenkins  (0) 2025.06.02
EKS Deployment  (0) 2025.05.29
EKS Ingress 설정  (0) 2025.05.28
EKS Cluster <> ASG 연동 (cluster-autoscaler)  (0) 2025.05.27