
인프런 워밍업 스터디 클럽 4기 데브옵스 - 미션2 (Probe)
Application 기능으로 이해하기 - Probe > 응용과제 [미션2]
Probe란?
Kubernetes에서 Probe는 컨테이너 상태를 체크하기 위한 매커니즘입니다.
startupProbe: 앱이 기동됐는지 확인
readinessProbe: 앱이 트래픽을 받을 준비가 되었는지 확인
livenessProbe: 앱이 살아있는지 확인
응용1. startupProbe가 실패하도록 설정해서 Pod가 무한 재기동 상태가 되도록 하라
방법
startupProbe:
httpGet:
path: "/startup"
port: 8080
periodSeconds: 5
failureThreshold: 1
readinessProbe:
httpGet:
path: "/readiness"
port: 8080
periodSeconds: 10
failureThreshold: 3
livenessProbe:
httpGet:
path: "/liveness"
port: 8080
periodSeconds: 10
failureThreshold: 3
/startup
엔드포인트가 기동 직후 실패하도록 App을 수정failureThreshold: 1
설정으로 한 번 실패하면 Pod는 무한 재시작
결과
kubectl get pods
로 확인 시, Pod가CrashLoopBackOff
상태로 반복 재기동kubectl describe pod
에서 startupProbe 실패 로그 확인
응용2. App이 부하로 인해 30초 뒤 트래픽이 중단되고, 3분 뒤 재기동 되게 하라
방법
livenessProbe:
httpGet:
path: "/liveness"
port: 8080
periodSeconds: 60
failureThreshold: 3
readinessProbe는 10초 주기로 3번 실패 시 트래픽 차단 (30초 후)
livenessProbe는 60초 주기로 3번 실패 시 재시작 (180초 후)
/server-load-on
API로 내부 상태 변경
결과
부하 API 호출 후, 30초 후에 서비스 응답 끊김 (
kubectl describe pod
로 확인)약 3분 뒤에 livenessProbe에 의해 자동 재기동
응용3. readinessProbe로 Secret 파일 존재 여부를 확인하라
방법
readinessProbe:
exec:
command: ["cat", "/usr/src/myapp/datasource/postgresql-info.yaml"]
periodSeconds: 10
failureThreshold: 3
해당 경로에 Secret 파일이 존재하지 않으면
readinessProbe
실패파일이 생성된 후에야 서비스로 트래픽 전달 가능
결과
파일 존재하지 않을 때
NotReady
상태 유지kubectl logs
로 command 실행 실패 확인파일 생성 후, Pod가 Ready 상태로 전환됨
미션2 소감
Kubernetes의 Probe는 단순한 헬스체크가 아닌, 운영자의 철학을 반영하여 정교하게 확인하는 것을 알게 되었음
오동작보다 무서운 것은 오동작을 감지하지 못하는 것이고, Probe는 그 위험을 미연에 막아주는 역할
댓글을 작성해보세요.