본문 바로가기

리눅스

[draft] Kubernetes에서 자주 사용되는 애플리케이션 배포 전략

Kubernetes에서 자주 사용되는 애플리케이션 배포 전략(Deployment Strategies)

1. Recreate (완전 교체 배포)

동작 방식

  • 기존 파드를 전부 종료한 뒤 새 버전 파드를 생성
  •  → 한 시점에는 오직 하나의 버전만 존재

출처-https://storage.googleapis.com/cdn.thenewstack.io/media/2017/11/c42fa239-recreate.gif

Kubernetes 설정 예시

strategy:
  type: Recreate
  • 특징: 배포 중 서비스 중단 발생 사용
  • 예시: 개발/테스트 환경, 비중요 서비스

2. Rolling Update(Ramped)

동작 방식

  • 새 버전을 하나씩 배포하면서, 기존 파드를 점진적으로 제거
  • → 무중단 배포 가능 (Kubernetes 기본 전략)

출처-https://storage.googleapis.com/cdn.thenewstack.io/media/2017/11/5bddc931-ramped.gif

Kubernetes 설정 예시:

strategy:
  type: RollingUpdate
  rollingUpdate:
    maxSurge: 1
    maxUnavailable: 1

특징

  • 실시간 트래픽 유지
  • 일부 파드는 구버전, 일부는 신버전인 혼합 상태 발생 가능

사용 예시: 대부분의 일반 프로덕션 서비스

3. Blue/Green Deployment

동작 방식

  • 기존 버전: Blue
  • 새 버전: Green
    • 두 버전을 완전히 분리된 환경에 띄워 놓고, 트래픽을 한 번에 Green으로 전환

출처-https://storage.googleapis.com/cdn.thenewstack.io/media/2017/11/73a2824d-blue-green.gif

특징

  • 빠른 롤백 가능(트래픽을 다시 Blue로 돌리면 끝)
  • 자원 2배 사용

구현 예시

  • Ingress, LoadBalancer, Service를 활용해 트래픽 전환

4. Canary Deployment

동작 방식

  • 새 버전을 일부 사용자(예: 5%, 10%)에게만 배포
  • 문제 없으면 점차 비율을 높임

출처-https://storage.googleapis.com/cdn.thenewstack.io/media/2017/11/a6324354-canary.gif

특징

  • 실제 트래픽 기반 안정성 검증
  • 트래픽 분할 제어 필요 (Ingress Controller, Service Mesh 활용)

대표 툴

  • Argo Rollouts
  • Flagger(Weaveworks)

5. A/B Testing

동작 방식

  • 트래픽을 특정 조건(예: 사용자 그룹, 지역, 쿠키 값)에 따라 서로 다른 버전으로 라우팅 결과를 측정해 기능/UX 개선

출처-https://storage.googleapis.com/cdn.thenewstack.io/media/2017/11/5deeea9c-a-b.gif

특징

  • 실험/마케팅 중심 배포 전략
  • 세분화된 라우팅 로직 필요

사용 도구

  • Istio, Envoy, Nginx Ingress Controller

6. Shadow Deployment(Traffic Mirroring)

동작 방식

  • 실제 트래픽을 신버전으로 복제(mirror) 하여 테스트
  • 응답은 무시되므로 사용자 영향 없음

출처-https://storage.googleapis.com/cdn.thenewstack.io/media/2017/11/fdd947f8-shadow.gif

특징

  • 실제 트래픽 부하/패턴을 테스트 가능
  • 리소스 및 네트워크 비용 증가

사용 도구

  • Istio mirror, Nginx mirror directive

요약 시각화

[ 단순함 ]──────────────────────────────────────────▶[ 복잡함 ]
  Recreate → Rolling Update → Blue/Green → Canary → A/B → Shadow
        ▲                  ▲                  ▲
   서비스 중단          무중단 배포         실시간 검증

 

kubectl explain deploy.spec.strategy
$ kubectl explain deploy.spec.strategy
KIND:     Deployment
VERSION:  apps/v1

RESOURCE: strategy <Object>

DESCRIPTION:
     The deployment strategy to use to replace existing pods with new ones.

     DeploymentStrategy describes how to replace existing pods with new ones.

FIELDS:
   rollingUpdate	<Object>
     Rolling update config params. Present only if DeploymentStrategyType =
     RollingUpdate.

   type	<string>
     Type of deployment. Can be "Recreate" or "RollingUpdate". Default is
     RollingUpdate.

 

참고URL

- https://thenewstack.io/deployment-strategies/

- https://cloud.google.com/architecture/application-deployment-and-testing-strategies?hl=ko

- https://www.ciokorea.com/news/157642