소프트웨어 배포 전략은 서비스 중단 없이 새 버전을 안전하게 배포하는 방법이다. 각 전략은 리스크, 복잡도, 롤백 속도가 다르다.
주요 배포 전략 비교
| 전략 | 다운타임 | 롤백 속도 | 리소스 비용 | 복잡도 |
|---|
| 재배포 (Recreate) | 있음 | 느림 | 낮음 | 낮음 |
| 롤링 업데이트 | 없음 | 보통 | 낮음 | 낮음 |
| 블루/그린 | 없음 | 즉시 | 2배 | 중간 |
| 카나리 | 없음 | 즉시 | 약간 추가 | 높음 |
| A/B 테스트 | 없음 | 즉시 | 약간 추가 | 매우 높음 |
| 섀도우 | 없음 | - | 2배 | 높음 |
yaml
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1 # 동시 종료 최대 파드 수
maxSurge: 1 # 초과 생성 최대 파드 수
블루/그린 배포 (Kubernetes)
yaml
# Green 배포 (새 버전)
kubectl apply -f deployment-green.yaml
# 헬스체크 후 트래픽 전환
kubectl patch service my-app -p '{"spec":{"selector":{"version":"green"}}}'
# 문제 발생 시 즉시 롤백
kubectl patch service my-app -p '{"spec":{"selector":{"version":"blue"}}}'
카나리 배포 (Argo Rollouts)
yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: my-app
spec:
strategy:
canary:
steps:
- setWeight: 10 # 10% 트래픽
- pause: {duration: 5m}
- setWeight: 30
- pause: {duration: 10m}
- analysis:
templates:
- templateName: success-rate
- setWeight: 100
canaryService: my-app-canary
stableService: my-app-stable
피처 플래그 (A/B 테스트)
typescript
// LaunchDarkly/OpenFeature 예시
const variation = await ldClient.variation(
'new-checkout-flow',
{ key: userId, email: userEmail },
false // 기본값
);
if (variation) {
return renderNewCheckout();
} else {
return renderOldCheckout();
}