Kubernetes Zero-Downtime 배포
운영 중인 서비스를 끊김 없이 배포하는 건 생각보다 까다롭다.
핵심 설정
1. Readiness Probe 정확히 설정
readinessProbe:
httpGet:
path: /health/ready
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 3
2. PodDisruptionBudget 설정
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: api-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: api
3. Graceful Shutdown
preStop hook으로 커넥션 정리 시간 확보:
lifecycle:
preStop:
exec:
command: ["sh", "-c", "sleep 10"]
실수했던 것
처음에 readinessProbe 없이 배포했다가, 아직 준비 안 된 Pod로 트래픽이 가서 장애가 났다. Probe는 필수다.