시작하기 - AWS Load Balancer Controller
이 가이드는 Argo Rollouts가 트래픽 셰이핑을 위해 AWS Load Balancer Controller와 어떻게 통합되는지 설명해요. 기본 시작하기 가이드의 개념을 바탕으로 진행해요.
출처: 문서
본문
이 가이드는 Argo Rollouts가 트래픽 셰이핑을 위해 AWS Load Balancer Controller와 어떻게 통합되는지 설명해요. 이 가이드는 기본 시작하기 가이드의 개념을 바탕으로 진행해요.
Requirements
- AWS ALB Ingress Controller가 설치된 Kubernetes 클러스터
Tip
AWS Load Balancer Controller 설치 방법은 Load Balancer Controller Installation 안내를 참고해요.
1. Deploy the Rollout, Services, and Ingress
AWS ALB Ingress가 트래픽 라우터로 사용될 때, Rollout canary 전략은 다음 필드를 정의해야 해요:
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
spec:
strategy:
canary:
# canaryService and stableService are references to Services which the Rollout will modify
# to target the canary ReplicaSet and stable ReplicaSet respectively (required).
canaryService: rollouts-demo-canary
stableService: rollouts-demo-stable
trafficRouting:
alb:
# The referenced ingress will be injected with a custom action annotation, directing
# the AWS Load Balancer Controller to split traffic between the canary and stable
# Service, according to the desired traffic weight (required).
ingress: rollouts-demo-ingress
# Reference to a Service that the Ingress must target in one of the rules (optional).
# If omitted, uses canary.stableService.
rootService: rollouts-demo-root
# Service port is the port which the Service listens on (required).
servicePort: 443
...
Rollout이 참조하는 Ingress에는 Rollout 서비스 중 하나와 일치하는 규칙이 있어야 해요. 이는 canary.trafficRouting.alb.rootService(지정한 경우)여야 하며, 그렇지 않으면 Rollout이 canary.stableService를 사용해요.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: rollouts-demo-ingress
annotations:
kubernetes.io/ingress.class: alb
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
# serviceName must match either: canary.trafficRouting.alb.rootService (if specified),
# or canary.stableService (if rootService is omitted)
name: rollouts-demo-root
# servicePort must be the value: use-annotation
# This instructs AWS Load Balancer Controller to look to annotations on how to direct traffic
port:
name: use-annotation
업데이트 중에 Ingress에는 사용자 지정 action annotation이 주입돼요. 이 annotation은 ALB가 Rollout이 참조하는 stable과 canary 서비스 사이에서 트래픽을 분할하도록 지시해요. 이 예제에서 해당 서비스 이름은 각각 rollouts-demo-stable과 rollouts-demo-canary예요.
다음 명령을 실행해 배포해요:
-
Rollout 하나
-
세 개의 서비스 (root, stable, canary)
-
Ingress 하나
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/alb/rollout.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/alb/services.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/alb/ingress.yaml
매니페스트를 적용하고 나면 클러스터에서 다음과 같은 rollout, services, ingress 리소스를 볼 수 있어요:
$ kubectl get ro
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE
rollouts-demo 1 1 1 1
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rollouts-demo-root NodePort 10.100.16.123 <none> 80:30225/TCP 2m43s
rollouts-demo-canary NodePort 10.100.16.64 <none> 80:30224/TCP 2m43s
rollouts-demo-stable NodePort 10.100.146.232 <none> 80:31135/TCP 2m43s
$ kubectl get ingress
NAME HOSTS ADDRESS PORTS AGE
rollouts-demo-ingress * b0548428-default-rolloutsd-6951-1972570952.ap-northeast-1.elb.amazonaws.com 80 6m36s
kubectl argo rollouts get rollout rollouts-demo
2. Perform an update
이미지를 변경해 rollout을 업데이트하고, paused 상태에 도달할 때까지 기다려요.
kubectl argo rollouts set image rollouts-demo rollouts-demo=argoproj/rollouts-demo:yellow
kubectl argo rollouts get rollout rollouts-demo
이 시점에서 Rollout의 canary와 stable 두 버전 모두 실행되고 있으며, 트래픽의 5%가 canary로 전달돼요. 이것이 어떻게 동작하는지 이해하려면 ALB의 listener rules를 확인해요. listener rules를 보면 컨트롤러가 forward action 가중치를 canary의 현재 가중치를 반영하도록 수정했음을 알 수 있어요.
컨트롤러는 Services에 rollouts-pod-template-hash 셀렉터를 추가하고 Pod에 동일한 라벨을 붙였어요. 따라서 가중치에 따라 요청을 서비스로 전달하기만 하면 트래픽을 분할할 수 있어요.
Rollout이 steps를 진행하면서 forward action 가중치는 steps의 현재 setWeight와 일치하도록 조정돼요.