Skip to main content

시작하기

개요

HPA(Horizontal Pod Autoscaler)는 기본적으로 CPU와 메모리 사용량을 기준으로 스케일링하지만, 이는 실제 웹 애플리케이션의 복잡한 부하 상황을 충분히 반영하지 못한다.
따라서 TPS, 지연 트랜잭션, 액티브 유저 수 등 APM 기반 커스텀 매트릭을 활용하면 사용자 경험 중심의 보다 정교한 오토스케일링이 가능하다.

설치 방법

helm install openmaru-apm ./openmaru-apm -f values.yaml --namespace openmaru-apm --create-namespace

셈플 애플리케이션

cat <<EOF | oc apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-tom
namespace: test-ns
labels:
app: test-tom
spec:
replicas: 1
selector:
matchLabels:
app: test-tom
template:
metadata:
labels:
app: test-tom
openmaru.io/was-agent: 'true'
spec:
containers:
- name: test-tom
image: registry.openmaru.io/image/openjdk11-tomcat9-ubi8:latest
EOF

HPA 등록

  • name: tps APM의 TPS 정보로 오토스케일링
  • apmAlias: APM-80-190 Operator ENV에 선언된 APM서버 정보
  • groupName: TOMCAT OPENMARU APM 그룹정보 (빌드 변경되는 Built-In이려면 User Defined 생성)
  • type: AverageValue APM에서 리턴한 TPS 값을 현재 파드 수로 나누어 파드당 평균 TPS를 계산한 후 사용
## POD당 평균 50TPS 를 초과 하면 최대 3개까지 오토스케일링
cat <<EOF | oc apply -f -
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: test-tom-hpa
namespace: test-ns
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: test-tom
minReplicas: 1
maxReplicas: 3
metrics:
- type: External
external:
metric:
name: tps
selector:
matchLabels:
apmAlias: APM-80-190
groupName: TOMCAT
target:
type: AverageValue
value: 50
EOF

확인 방법

$ k get test-tom-hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
test-tom-hpa Deployment/test-tom 65/100 1 3 3 17m