개요

AWS EKS 환경에서 Prometheus, HPA, Cluster Autoscaler를 활용하여 효율적인 Autoscaling을 구현


각 구성 요소 설명

Prometheus

Horizontal Pod Autoscaler (HPA)

Cluster Autoscaler (CA)


적용 메트릭 및 설정 방식

# **bank-app-back-hpa.yaml**

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: hpa-backend-server
  namespace: bank-namespace
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: backend-server
  minReplicas: 1
  maxReplicas: 3
  metrics:
    - type: Pods
      pods:
        metric:
          name: node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate
        target:
          type: AverageValue
          averageValue: 0.3
    - type: Pods
      pods:
        metric: 
          name: container_memory_usage_bytes
        target:
          type: AverageValue
          averageValue: 524288000
    - type: Pods
      pods:
        metric:
          name: container_network_receive_bytes_total
        target:
          type: AverageValue
          averageValue: 1000000
    - type: Pods
      pods:
        metric:
          name: container_network_transmit_bytes_total
        target:
          type: AverageValue
          averageValue: 1000000

CPU 사용량

메모리 사용량

네트워크 트래픽


CA 활성화

Auto Scaling 그룹에 태그 추가

image.png

IAM 역할 설정: 노드 그룹의 IAM 역할에 Autoscaling 권한을 추가

image.png