๐น ๋ฐฐํฌ ์ ๋ต(Deployment Strategy)์ด ์ค์ํ ์ด์
Kubernetes ํ๊ฒฝ์์๋ ์๋ก์ด ์ ํ๋ฆฌ์ผ์ด์
๋ฒ์ ์ ๋ฐฐํฌํ ๋, ์๋น์ค ์ค๋จ ์์ด ์์ ์ ์ผ๋ก ๋ฐฐํฌํ๋ ๊ฒ์ด ๋งค์ฐ ์ค์ํฉ๋๋ค.
์ ํต์ ์ธ ๋ฐฐํฌ ๋ฐฉ์(์ฆ์ ๋ฐฐํฌ)์ ํธ๋ํฝ์ ํ ๋ฒ์ ์ ๋ฒ์ ์ผ๋ก ์ ํํ๊ธฐ ๋๋ฌธ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ ์๋น์ค ์ฅ์ ๊ฐ ๋ฐ์ํ ๊ฐ๋ฅ์ฑ์ด ๋์ต๋๋ค.
โ ์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ์ฌ์ฉ๋๋ ๋ํ์ ์ธ ๋ฐฐํฌ ์ ๋ต:
โ ๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ฐฐํฌ(Blue-Green Deployment) → ๋ ๊ฐ์ ํ๊ฒฝ(Blue์ Green) ์ค ํ๋๋ง ํ์ฑํ
โ ์นด๋๋ฆฌ ๋ฐฐํฌ(Canary Deployment) → ํธ๋ํฝ์ ์ผ๋ถ๋ง ์ ๋ฒ์ ์ผ๋ก ์ ์ง์ ์ ํ
Argo Rollouts๋ ์ด๋ฌํ ๊ณ ๊ธ ๋ฐฐํฌ ์ ๋ต์ ์ง์ํ๋ Kubernetes ์ปจํธ๋กค๋ฌ๋ก,
Argo CD์ ํจ๊ป ์ฌ์ฉํ๋ฉด GitOps ๊ธฐ๋ฐ์ ์ง์์ ์ธ ๋ฐฐํฌ ์๋ํ๋ฅผ ๊ตฌํํ ์ ์์ต๋๋ค.
๐น ๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ฐฐํฌ๋?
โ ๊ฐ๋ :
๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ฐฐํฌ๋ ํ์ฌ ์ด์ ์ค์ธ ๋ฒ์ (Blue)๊ณผ ์๋ก์ด ๋ฒ์ (Green)์ ๋์์ ์ ์งํ๋ฉด์, ํน์ ์์ ์ ํธ๋ํฝ์ Green์ผ๋ก ์ ํํ๋ ๋ฐฉ์์
๋๋ค.
๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ๋ค์ Blue๋ก ๋กค๋ฐฑํ ์ ์๊ธฐ ๋๋ฌธ์ ๋น ๋ฅธ ๋ณต๊ตฌ๊ฐ ๊ฐ๋ฅํฉ๋๋ค.
โ ๋์ ๋ฐฉ์:
1๏ธโฃ ๊ธฐ์กด ๋ฒ์ (Blue)์ ์ ์งํ ์ฑ, ์ ๋ฒ์ (Green)์ ๋ฐฐํฌ
2๏ธโฃ Green ๋ฒ์ ์ด ์ ์์ ์ผ๋ก ๋์ํ๋์ง ํ์ธ
3๏ธโฃ ํธ๋ํฝ์ ์ ์ง์ ์ผ๋ก Green์ผ๋ก ์ ํ
4๏ธโฃ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ์ฆ์ Blue๋ก ๋๋๋ฆผ
5๏ธโฃ ์์ ์ฑ์ด ํ์ธ๋๋ฉด Blue ํ๊ฒฝ์ ์ ๊ฑฐ
โ ์ฅ์ :
โ ์๋น์ค ์ค๋จ ์์ด ์๋ก์ด ๋ฒ์ ๋ฐฐํฌ ๊ฐ๋ฅ
โ ํธ๋ํฝ ์ ํ์ ํตํด ๋ฐฐํฌ ์์ ์ฑ ๋ณด์ฅ
โ ๋กค๋ฐฑ์ด ๋น ๋ฅด๊ณ ๊ฐ๋จํจ
โ ๋จ์ :
โ ๋ ๊ฐ์ ํ๊ฒฝ(Blue, Green)์ ๋์์ ์ ์งํด์ผ ํ๋ฏ๋ก ๋ฆฌ์์ค ์๋ชจ๊ฐ ๋ง์
๐น ์นด๋๋ฆฌ ๋ฐฐํฌ๋?
โ
๊ฐ๋
:
์นด๋๋ฆฌ ๋ฐฐํฌ๋ ์ผ๋ถ ์ฌ์ฉ์(์: 10%)๋ง ์ ๋ฒ์ ์ ์ฌ์ฉํ๋๋ก ํ์ฌ ๋ฌธ์ ๊ฐ ์๋์ง ์ ์ง์ ์ผ๋ก ํ์ธํ๋ ๋ฐฉ์์
๋๋ค.
์ ์ง์ ์ธ ํธ๋ํฝ ์ด๋์ ํตํด ๋ฌธ์ ๋ฐ์ ์ ์ํฅ์ ์ต์ํํ ์ ์์ต๋๋ค.
โ ๋์ ๋ฐฉ์:
1๏ธโฃ ๊ธฐ์กด ๋ฒ์ (A)๊ณผ ์ ๋ฒ์ (B)์ ๋์์ ์ด์
2๏ธโฃ ์ผ๋ถ ํธ๋ํฝ(์: 10%)์ ์ ๋ฒ์ ์ผ๋ก ์ ์ก
3๏ธโฃ ์์ ์ฑ์ด ํ์ธ๋๋ฉด ์ ์ง์ ์ผ๋ก ํธ๋ํฝ์ ๋๋ฆผ (์: 10% → 30% → 60% → 100%)
4๏ธโฃ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ์ฆ์ ๊ธฐ์กด ๋ฒ์ ์ผ๋ก ๋กค๋ฐฑ
โ
์ฅ์ :
โ ์๋น์ค ์์ ์ฑ์ด ๋์ (์ ์ง์ ๋ฐฐํฌ)
โ ์ฅ์ ๋ฐ์ ์ ๋น ๋ฅธ ๋กค๋ฐฑ ๊ฐ๋ฅ
โ
๋จ์ :
โ ๋ฐฐํฌ ๋ฐ ํ
์คํธ ์๊ฐ์ด ์๋์ ์ผ๋ก ๊ธธ์ด์ง ์ ์์
โ ํธ๋ํฝ์ ์ ์ง์ ์ผ๋ก ์ด๋ํ๋ ์ถ๊ฐ์ ์ธ ๋ก์ง ํ์
๐น Argo Rollouts๋ฅผ ํ์ฉํ ๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ฐฐํฌ
Argo Rollouts๋ฅผ ์ฌ์ฉํ๋ฉด Kubernetes Deployment ๋์ Rollout ๋ฆฌ์์ค๋ฅผ ํ์ฉํ์ฌ ๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ฐฐํฌ๋ฅผ ์์ฝ๊ฒ ๊ตฌํํ ์ ์์ต๋๋ค.
โ Argo Rollouts ์ค์นํ๊ธฐ
๋จผ์ Argo Rollouts ์ปจํธ๋กค๋ฌ๋ฅผ Kubernetes ํด๋ฌ์คํฐ์ ๋ฐฐํฌํฉ๋๋ค.
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml
โ ์ค์น ํ์ธ:
kubectl get pods -n argo-rollouts
NAME READY STATUS RESTARTS AGE
argo-rollouts-5d6f8b5c79-xyzabc 1/1 Running 0 1m
โ Argo Rollouts ๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ฐฐํฌ ์์
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: example-app # ์ ํ๋ฆฌ์ผ์ด์
์ด๋ฆ
namespace: example-namespace # ๋ค์์คํ์ด์ค
spec:
replicas: 3 # ์คํํ ํ๋ ๊ฐ์
strategy:
blueGreen:
activeService: example-app-service # ๊ธฐ์กด ๋ฒ์ (Blue)์ ์ฐ๊ฒฐ๋ ์๋น์ค
previewService: example-app-preview # ์ ๋ฒ์ (Green)์ ์ฐ๊ฒฐ๋ ์๋น์ค
autoPromotionEnabled: false # ์๋ ํธ๋ํฝ ์ ํ ๋นํ์ฑํ (์๋ ์น์ธ ํ์)
selector:
matchLabels:
app: example-app
template:
metadata:
labels:
app: example-app
spec:
containers:
- name: app
image: ghcr.io/example/app:v2 # ์๋ก์ด ๋ฒ์ ์ ์ปจํ
์ด๋ ์ด๋ฏธ์ง
ports:
- containerPort: 80
โ ์ค๋ช :
- strategy.blueGreen.activeService → ํ์ฌ ์ด์ ์ค์ธ ์๋น์ค (Blue)
- strategy.blueGreen.previewService → ํ ์คํธ ์ค์ธ ์ ๋ฒ์ (Green)
- autoPromotionEnabled: false → ์๋ ์น๊ฒฉ ๋นํ์ฑํ (๊ด๋ฆฌ์๊ฐ ์น์ธํด์ผ ํธ๋ํฝ ์ ํ)
โ ๋ฐฐํฌ ํ ํธ๋ํฝ ์ ํ:
kubectl argo rollouts promote example-app
โ ๋กค๋ฐฑ ์ ๊ธฐ์กด ๋ฒ์ ์ผ๋ก ์ ํ:
kubectl argo rollouts abort example-app
๐น Argo Rollouts๋ฅผ ํ์ฉํ ์นด๋๋ฆฌ ๋ฐฐํฌ
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: example-app
namespace: example-namespace
spec:
replicas: 3
strategy:
canary:
steps:
- setWeight: 10 # 10% ํธ๋ํฝ์ ์ ๋ฒ์ ์ผ๋ก ์ ํ
- pause: {duration: 30s} # 30์ด ๋๊ธฐ
- setWeight: 50 # 50% ํธ๋ํฝ ์ ํ
- pause: {} # ๊ด๋ฆฌ์๊ฐ ์น์ธํ ๋๊น์ง ๋๊ธฐ
selector:
matchLabels:
app: example-app
template:
metadata:
labels:
app: example-app
spec:
containers:
- name: app
image: ghcr.io/example/app:v2
ports:
- containerPort: 80
โ ์ค๋ช :
- setWeight: 10 → ์ด๊ธฐ 10% ํธ๋ํฝ์ ์ ๋ฒ์ ์ผ๋ก ์ ํ
- pause: {duration: 30s} → 30์ด ๋์ ์์ ์ฑ ํ์ธ ํ ๋ค์ ๋จ๊ณ ์งํ
- setWeight: 50 → 50% ํธ๋ํฝ ์ ํ
- pause: {} → ๊ด๋ฆฌ์๊ฐ ์น์ธํ ๋๊น์ง ๋๊ธฐ
โ ์นด๋๋ฆฌ ๋ฐฐํฌ ์งํ ์ํฉ ํ์ธ:
kubectl argo rollouts get rollout example-app
โ ์นด๋๋ฆฌ ๋ฐฐํฌ ์น์ธ:
kubectl argo rollouts promote example-app
โ ๋กค๋ฐฑ ์ ๊ธฐ์กด ๋ฒ์ ์ ์ง:
kubectl argo rollouts abort example-app
๐น ๊ฒฐ๋ก : ์ด๋ฒ ๊ธ์์ ๋ฐฐ์ด ํต์ฌ ๋ด์ฉ ์ ๋ฆฌ
๐ข ๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ฐฐํฌ๋ ๋ ๊ฐ์ ํ๊ฒฝ์ ์ ์งํ๋ฉด์ ๋น ๋ฅด๊ฒ ๋กค๋ฐฑ ๊ฐ๋ฅํ์ง๋ง ๋ฆฌ์์ค ์ฌ์ฉ๋์ด ๋ง์
๐ข ์นด๋๋ฆฌ ๋ฐฐํฌ๋ ์ ์ง์ ์ผ๋ก ํธ๋ํฝ์ ์ด๋์ํค๋ฉด์ ์์ ์ฑ์ ๋์ผ ์ ์์
๐ข Argo Rollouts๋ฅผ ํ์ฉํ๋ฉด ๋ธ๋ฃจ-๊ทธ๋ฆฐ ๋ฐ ์นด๋๋ฆฌ ๋ฐฐํฌ๋ฅผ ์๋ํํ๊ณ GitOps ๊ธฐ๋ฐ์ผ๋ก ์ด์ ๊ฐ๋ฅ