본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

시작하기: AWS Load Balancer Controller (ALB)

원문 보기 위키 갱신

이 문서는 Argo Rollouts가 트래픽 분산을 위해 AWS Load Balancer Controller와 통합되는 방식을 다룹니다. 기본 시작 가이드의 개념을 바탕으로 진행하며, ALB를 트래픽 라우터로 사용하는 Rollout 배포부터 업데이트까지 전체 흐름을 설명해 드립니다.

출처: Argo Rollouts 문서

본문

이 가이드는 트래픽 분산(shaping)을 위해 Argo Rollouts가 AWS Load Balancer Controller와 통합되는 방식을 다룹니다. 이 가이드는 기본 시작 가이드의 개념에 기반합니다.

요구 사항 (Requirements)

  • AWS ALB Ingress Controller가 설치된 Kubernetes 클러스터

팁 (tip)

AWS Load Balancer Controller 설치 방법은 Load Balancer Controller 설치 지침을 참고하세요.

1. Rollout, Services, 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의 서비스 중 하나와 일치하는 규칙(rule)을 가져야 합니다. 이는 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에는 커스텀 액션 주석이 주입되며, 이는 ALB가 Rollout이 참조하는 stable과 canary Service 사이의 트래픽을 분할하도록 지시합니다. 이 예제에서 해당 Service는 각각 rollouts-demo-stable과 rollouts-demo-canary입니다.

다음 명령을 실행하여 배포합니다.

  • A Rollout
  • Three Services (root, stable, canary)
  • An 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, 서비스, 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

Rollout ALB

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 ALB Paused

이 시점에서 Rollout의 canary와 stable 버전이 모두 실행 중이며, 트래픽의 5%가 canary로 보내집니다. 이것이 어떻게 동작하는지 이해하려면 ALB의 리스너 규칙(listener rules)을 검사해 보세요. 리스너 규칙을 보면 컨트롤러가 canary의 현재 가중치를 반영하도록 forward action의 가중치를 수정한 것을 확인할 수 있습니다.

ALB Listener_Rules

컨트롤러는 Services에 rollouts-pod-template-hash selector를 추가하고 동일한 라벨을 Pods에 부착했습니다. 따라서 가중치에 따라 요청을 Services로 전달하기만 하면 트래픽을 분할할 수 있습니다.

Rollout이 단계를 진행함에 따라 forward action의 가중치는 단계의 현재 setWeight와 일치하도록 조정됩니다.

더 알아보기 (Learn more)

  • 기본 시작 가이드에서 Rollout의 기본 개념 익히기
  • Canary 배포 전략과 단계(step) 구성 방법 알아보기
  • Istio 트래픽 라우터를 사용한 트래픽 분산 방식 살펴보기
  • AWS Load Balancer Controller의 액션 주석과 가중치 분산 원리 이해하기