728x90
반응형
global-prod-cluster의 global-settle-api 파드가 재생성 시 정상적으로 뜨지 못하고 HPA에 의해 강제 스케일 다운되는 현상이 반복적으로 발생.
수동으로 파드를 삭제해야만 정상화되는 상황.
원인 분석 결과, Spring Boot 기동 시간이 readinessProbe 실패 판정 시간(45초)을 초과하여 파드가 Unready 상태로 확정되고,
HPA가 메트릭 수집 불가 상태에서 "All metrics below target"으로 판단해 기동 중인 파드를 강제 삭제하는 흐름이 확인.
# NS 이벤트만 조회
# 마지막 발생 시간 기준으로 오래된 것부터
kubectl get events -n {Namespace} \
--sort-by='.lastTimestamp' \
--context {aws_ARN}:cluster/{cluster_name}
기존 코드
ports:
- containerPort: 8080
name: http
protocol: TCP
readinessProbe:
initialDelaySeconds: 30
periodSeconds: 5
httpGet:
path: /actuator/health
port: http
기존 코드의 흐름
파드 생성됨
Spring Boot 기동 중 (아직 8080 포트 안 열림)
30초 후 readinessProbe 시작
↓
connection refused → probe 실패 (5초 x 3회 = 15초)
↓
파드 Unready 상태
↓
HPA: 메트릭 수집 불가 → "All metrics below target"
↓
HPA가 스케일 다운 결정 → 기동 중인 파드 강제 삭제
↓
다시 1번부터 반복 → 영원히 못 뜸
-> Spring Boot 기동 시간(30초 이상)이 probe 실패 판정 시간(45초)보다 길어서 HPA가 계속 죽이는 것
--
수정 코드 (startupProbe 추가)
ports:
- containerPort: 8080
name: http
protocol: TCP
# startupProbe: Spring Boot 기동 완료 전까지 readiness/liveness probe 차단
# failureThreshold(20) x periodSeconds(10) = 최대 200초 대기
# 통과 전까지 HPA가 Unready 파드를 스케일 다운하는 문제 방지
startupProbe:
httpGet:
path: /actuator/health
port: http
failureThreshold: 20
periodSeconds: 10
# startupProbe 통과 후 즉시 readiness 체크 시작 (initialDelaySeconds 0으로 변경)
readinessProbe:
initialDelaySeconds: 0
수정 코드의 흐름
파드 생성됨
startupProbe 시작 (최대 200초 대기)
Spring Boot 기동 완료 → startupProbe 통과
↓
그때부터 readinessProbe 시작
↓
파드 Ready → HPA 메트릭 정상 수집
↓
스케일 다운 없음
→ startupProbe가 기동 완료될 때까지 HPA가 건드리지 못하게 막아주는 역할728x90
반응형