ArgoCD 없이 Rollouts를 사용할 수 있을까?
Yes 사용 가능
막상 설치해보면 독립적인 솔루션이다 (대시보드가 독립적으로 있음)
다만 ArcoCD를 사용하면 Rollouts를 위한 버튼이 더 생기는 것
Blue/Green 배포
- 배포 시 롤백이 빠름
- 배포 중 v1, v2 동시 호출 없음
- Script를 통해 자동 배포 가능
- v2에 과도한 트래픽 유입시 문제 발생
Rollouts 설치 후
1. Rollout 컨트롤러 만들어짐
(k8s는 CRD라고 누구나 커스텀 리소스를 만들 수 있다-go 언어 로직 개발 필요, 이걸로 Replicaset 등 동작 변형이 가능하다)
2. 핵심 Service 2개 지정
1) 실제 서비스 사용자가 들어오는 Active Service
2) 업그레이드 중 v2로만 들어갈 수 있는 Preview Service
Blue/Green Upgrade 실제 동작
Rollouts의 태그 변경 -> Sync혹은 k8s 자원 수정 -> v2버전 ReplicaSet 생성 -> v2버전 Pod 생성 -> Preview Service는 v2 Pod로 연결
Canary 배포
setWeight: 전체 Pod에서 v2 pod가 차지하는 비율이 33%가 되도록 함
pause: promote 명령까지 부안정 대기
=> 서서히 전환을 하는 것
duration: 2m : 2분간 대기
실습
Rollouts 생성하기
[NEW APP] > [EDIT AS YAML]
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: api-tester-2233
spec:
destination:
name: ''
namespace: anotherclass-223
server: 'https://kubernetes.default.svc'
source:
path: 2233/deploy/argo-rollouts
repoURL: 'https://github.com/leesunmi99/kubernetes-anotherclass-sprint2.git'
targetRevision: main
sources: []
project: default
[CREATE]
문제1)
rollout.yaml 에서 lpro -> 1pro로 오타 수정함
생성된 리소스 확인하기
▲ deployment대신 Rollout controller가 ReplicaSet을 만들고 있음
▲ active Service, preview Service 확인
트래픽 보내보기
# Active Service
while true; do curl http://192.168.56.30:32233/version; sleep 2; echo ''; done;
# Preview Service
while true; do curl http://192.168.56.30:32243/version; sleep 2; echo ''; done;
https://argo-rollouts.readthedocs.io/en/stable/features/bluegreen/
파일 내용(기존 파일과 비교)
apiVersion: v1
kind: Service
metadata:
name: api-tester-2233-active
▲ active를 붙여줌
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: api-tester-2233
labels:
part-of: k8s-anotherclass
...
spec:
replicas: 2
strategy:
blueGreen:
activeService: api-tester-2233-active
previewService: api-tester-2233-preview
autoPromotionEnabled: false
▲ Rollout 리소스 생성
▲ autoPromotionEnabled: false 는 새 그린 파드가 정상적으로 기동 된 이후 promote 버튼을 눌러야 자동 배포 진행됨
(야간에 자동으로 배포 시키고 싶을 때 true로 하면 된다)
Blue/Green 배포 진행하기
1. Git에서 이미지 태그 변경후 commit
2. refresh 버튼 클릭
▲ 변경 사항 있음
▲ Preview pod는 아직 기동되지 않아서 에러남
본 서비스는 잘 호출되므로 문제있는 상황은 아님
▲ 왼쪽이 Active Service, 오른쪽이 Preview Service
labels 확인하기
▲ Pod에 rollouts-pod-template-hash 라는 labels가 추가됨
▲ Preview Service에 같은 이름의 Selector가 있음
(ReplicaSet에도 동일한 내용이 존재함 )
Promote 진행하기
방법1) ArgoCD의 대시보드에서 Promote
방법2) ArcoCD Rollouts 대시보드에서 Promote
ArgoCD Rollouts Dashboard
http://192.168.56.30:30003/rollouts/anotherclass-223
기능 Restart: 두 Pod가 하나씩 재생성됨 (쓸일 없음 - 만약 재생성 시키고 싶으면 Kubernetes에서 직접 삭제)
Promote: 다음 단계로 넘어감
Promote-full: 모든 단계를 넘어감
CLI로 진행하기
ArgoCD는 CLI를 쓸일이 없지만, Rollouts는 자주 쓰다보면 더 편해짐
이후 api-tester-2233 삭제
canary 배포 진행하기
# kubectl로 Rollouts 배포
kubectl apply -f https://raw.githubusercontent.com/k8s-1pro/kubernetes-anotherclass-sprint2/main/2234/deploy/argo-rollouts/rollout.yaml -n anotherclass-223
kubectl apply -f https://raw.githubusercontent.com/k8s-1pro/kubernetes-anotherclass-sprint2/main/2234/deploy/argo-rollouts/configmap.yaml -n anotherclass-223
kubectl apply -f https://raw.githubusercontent.com/k8s-1pro/kubernetes-anotherclass-sprint2/main/2234/deploy/argo-rollouts/secret.yaml -n anotherclass-223
kubectl apply -f https://raw.githubusercontent.com/k8s-1pro/kubernetes-anotherclass-sprint2/main/2234/deploy/argo-rollouts/service.yaml -n anotherclass-223
//조회
kubectl argo rollouts get rollout api-tester-2234 -n anotherclass-223 -w
while true; do curl http://192.168.56.30:32234/version; sleep 2; echo ''; done;
배포 시작
// 방법1) 직접 edit 로 수정하기
// kubectl argo rollouts edit <ROLLOUT_NAME> -n <NAMESPACE_NAME>
kubectl argo rollouts edit api-tester-2234 -n anotherclass-223
// 방법2) image 수정하기
// kubectl argo rollouts set image <ROLLOUT_NAME> <CONTAINER_NAME>=<IMAGE>:<TAG> -n <NAMESPACE_NAME>
kubectl argo rollouts set image api-tester-2234 api-tester-2234=1pro/api-tester:2.0.0 -n anotherclass-223
- Step1. Set Weight: 33% : Stable 2 pod, Canary 1 pod 상태로 만듬
- Step2. Pause : Promote 클릭 때까지 멈춤
- Step3. Set Weight: 66% : Stable 1 pod, Canary 2 pod 상태로 만듬
- Step4. Pause (2m) : 2분 동안 멈춤
- Step5. : Canary 2 pod 상태로 만듬
Pod가 종료되면서 v2.0.0만 호출된다.
리소스 정리
kubectl delete -f https://raw.githubusercontent.com/k8s-1pro/kubernetes-anotherclass-sprint2/main/2234/deploy/argo-rollouts/rollout.yaml -n anotherclass-223
kubectl delete -f https://raw.githubusercontent.com/k8s-1pro/kubernetes-anotherclass-sprint2/main/2234/deploy/argo-rollouts/configmap.yaml -n anotherclass-223
kubectl delete -f https://raw.githubusercontent.com/k8s-1pro/kubernetes-anotherclass-sprint2/main/2234/deploy/argo-rollouts/secret.yaml -n anotherclass-223
kubectl delete -f https://raw.githubusercontent.com/k8s-1pro/kubernetes-anotherclass-sprint2/main/2234/deploy/argo-rollouts/service.yaml -n anotherclass-223
'인프런 복습 - 쿠버네티스 어나더 클래스' 카테고리의 다른 글
[Sprint3] 가상화 한방정리 (0) | 2025.06.23 |
---|---|
[Sprint2] ArgoCD 설치과정 총정리 (1) | 2025.06.05 |
[Sprint2] ArgoCD Image Updater 이용하기 (0) | 2025.06.03 |
[Sprint2] ArgoCD 설치 및 Application 생성해보기 (1) | 2025.06.02 |
[Sprint2] 배포 파이프라인 구축 후 마주하게 되는 고민들 (1) | 2025.05.31 |