Argo Rollout는 쿠버네티스 기반의 Progressive 배포 솔루션이다. 기존 K8S 운영 환경에서 배포되는 방법은 주로 RollingUpdate를 사용하지만 Argo Rollout을 이용하여 Blue/Green 배포, Canary 배포를 사용하여 기존 방식에 비해 더 안정적이고 빠른 배포 파이프라인을 구축할 수 있게 도와준다. ArgoCD를 설치하지 않고 사용할 수 있지만 ArgoCD와 연동이 잘 되어있어 GitOps 방식으로 Argo Rollout을 사용할 수 있다.
# create namespace
kubectl create ns argo-rollouts
# Add argo repository
helm repo add argo https://argoproj.github.io/argo-helm
# Install argo-rollouts
helm -n argo-rollouts install argo-rollouts argo/argo-rollouts
# Delete argo-rollouts using helm
# helm -n argo-rollouts uninstall argo-rollouts
curl -LO https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64
sleep 1
chmod +x ./kubectl-argo-rollouts-linux-amd64
sleep 1
sudo mv ./kubectl-argo-rollouts-linux-amd64 /usr/local/bin/kubectl-argo-rollouts
sleep 1
# installation completed
sleep 1
# version
kubectl argo rollouts version
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: {{ .Values.name }}
spec:
replicas: {{ .Values.replicaCount }} # 3
revisionHistoryLimit: 5
selector:
matchLabels:
app: {{ .Values.name }}
template:
metadata:
labels:
app: {{ .Values.name }}
spec:
containers:
- name: {{ .Values.name }}
image: argoproj/rollouts-demo:{{ .Values.version }}
ports:
- containerPort: 8080
readinessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 10
periodSeconds: 10
strategy:
blueGreen:
activeService: {{ .Values.name }}-active
previewService: {{ .Values.name }}-preview
autoPromotionEnabled: false
previewReplicaCount: 1
strategy:blueGreen:activeService
strategy:blueGreen:previewService
strategy:blueGreen:autoPromotionEnabled
strategy:blueGreen:previewReplicaCount
초기
Prod:3
, Pre-Prod:0
Rollout 배포
Prod:3
, Pre-Prod:1
Promote-Full
Promote-Full 후
Prod:3
, Pre-Prod:3
Prod:3
, Pre-Prod:0
최종
apiVersion: argoproj.io/v1alpha1 # Changed from apps/v1
kind: Rollout # Changed from Deployment
metadata:
name: rollouts-demo
spec:
selector:
matchLabels:
app: rollouts-demo
replicas: 5 # <---- 5
template:
metadata:
labels:
app: rollouts-demo
spec:
containers:
- name: rollouts-demo
image: argoproj/rollouts-demo:blue
ports:
- containerPort: 8080
strategy:
blueGreen: # Changed from rollingUpdate or recreate
activeService: sample-service-active
previewService: sample-service-preview
autoPromotionEnabled: false
previewReplicaCount: 1