반응형
사전 준비
- Prometheus 설치
저 같은 경우 helm 차트를 사용하여 kube-prometheus-stack을 설치 해두었습니다.
KEDA 설치
KEDA 란?
KEDA(Kubernetes-based Event Driven Autoscaling)는 Kubernetes에서 이벤트 기반 자동 스케일링(Event-Driven Autoscaling) 을 제공하는 오픈소스 컴포넌트입니다.
일반적인 HPA(Horizontal Pod Autoscaler)로는 대응하기 어려운 메시지 큐, Kafka, 데이터베이스 등의 외부 이벤트를 기반으로 파드의 수를 자동 조절할 수 있게 해줍니다.
이제 Helm을 사용하여 설치 해보겠습니다.
- Helm repo 등록
helm repo add kedacore https://kedacore.github.io/charts- values.yaml 파일 수정
prometheus:
metricServer:
enabled: true <- false에서 true로 변경
serviceMonitor:
enabled: true <- false에서 true로 변경
additionalLabels:
release: monitor <- Prometheus-Operator의 ServiceMonitor에서 사용하는 라벨 입력
operator:
# -- Enable KEDA Operator prometheus metrics expose
enabled: true < false에서 true로 변경- KEAD 설치
helm install keda kedacore/keda -f values.yaml파드 오토스케일링 설정
KEDA 설치가 정상적으로 되면, 이제 ScaledObject 리소스를 사용하여
파드가 실시간으로 사용하는 메모리 양에 따라 스케일 인/아웃을 해주도록 하겠습니다.
vi scaledObject.yaml
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: <원하는 이름 설정>
namespace: <원하는 네임스페이스 설정>
spec:
scaleTargetRef:
apiVersion: argoproj.io/v1alpha1 <- 저 같은 경우 Rollout 리소스를 사용해서 Rollout 으로 정의해두었습니다.
kind: Rollout
name: <현재 사용하고 있는 Rollout 리소스의 이름 설정>
pollingInterval: 15
cooldownPeriod: 60
minReplicaCount: 2
maxReplicaCount: 4
triggers:
- type: prometheus
metadata:
serverAddress: http://monitor-kube-prometheus-st-prometheus.monitor.svc.cluster.local:9090 <- 실제 프로메테우스 서비스 도메인 넣기
metricName: container_memory_usage_bytes
query: |
sum(container_memory_working_set_bytes{namespace="outcode", pod=~"ask-engine-.*"})
threshold: "300000000" # 300MiB위와 같이 설정을 해두면, 파드의 메모리 사용량이 300MB가 넘으면 스케일 아웃이 됩니다.
이상 입니다.
반응형
'쿠버네티스' 카테고리의 다른 글
| Kubernetes에 Bitnami PostgreSQL 배포 가이드 (0) | 2025.11.10 |
|---|---|
| EKS 클러스터에서 GPU 자원 사용 (0) | 2025.06.16 |
| 파드 내 외부 통신 오류 (calico node already using the IPv4 address) (0) | 2025.04.20 |
| POD 생성 시 kyverno error 해결 (0) | 2025.01.06 |
| Helm 차트로 설치한 어플리케이션의 values.yaml 내용 확인하기 (0) | 2025.01.06 |