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

시작하기 — 여러 트래픽 공급자 (Getting Started — Multiple Providers)

원문 보기 위키 갱신

이 가이드는 Argo Rollouts가 여러 TrafficRouting과 통합되는 방법을 다룹니다. 예제에서는 Linkerd(SMI)와 NGINX Ingress Controller를 함께 사용해 트래픽 셰이핑을 수행하지만, 기존 trafficRouting 옵션 간의 어떤 조합이든 만들 수 있어요. 기본 시작 가이드, NGINX 가이드, SMI 가이드의 개념을 바탕으로 진행됩니다.

출처: Argo Rollouts 문서

본문

중요 (Important, Available since v1.2) 이 가이드는 Linkerd와 NGINX Ingress Controller를 사용한 트래픽 셰이핑으로 Argo Rollouts가 여러 TrafficRouting과 통합되는 방법을 다룹니다. 하지만 기존 trafficRouting 옵션 간의 어떤 조합이든 생성할 수 있습니다.

이 가이드는 기본 시작 가이드, NGINX 가이드, SMI 가이드의 개념을 바탕으로 합니다.

요구 사항 (Requirements)

  • Linkerd가 설치된 Kubernetes 클러스터
  • NGINX ingress controller가 설치되어 있고 mesh에 포함된 Kubernetes 클러스터

팁 (Tip) linkerd와 nginx가 있는 로컬 minikube 환경을 설정하는 방법은 linkerd의 환경 설정 가이드를 참조하세요.

1. Rollout, Services, Ingress 배포

SMI를 트래픽 라우터 중 하나로 사용할 때 Rollout canary 전략은 다음 필수 필드를 정의해야 합니다:

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollouts-demo
spec:
  strategy:
    canary:
      # Reference to a Service which the controller will update to point to the canary ReplicaSet
      canaryService: rollouts-demo-canary
      # Reference to a Service which the controller will update to point to the stable ReplicaSet
      stableService: rollouts-demo-stable
      trafficRouting:
        smi: {}

NGINX Ingress를 트래픽 라우터로 사용할 때 Rollout canary 전략은 다음 필수 필드를 정의해야 합니다:

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollouts-demo
spec:
  strategy:
    canary:
      # Reference to a Service which the controller will update to point to the canary ReplicaSet
      canaryService: rollouts-demo-canary
      # Reference to a Service which the controller will update to point to the stable ReplicaSet
      stableService: rollouts-demo-stable
      trafficRouting:
        nginx:
          # Reference to an Ingress which has a rule pointing to the stable service (e.g. rollouts-demo-stable)
          # This ingress will be cloned with a new name, in order to achieve NGINX traffic splitting.
          stableIngress: rollouts-demo-stable
...

두 가지의 조합은 각 TrafficRouting의 요구 사항을 모두 충족해야 합니다. 이 경우:

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollouts-demo
spec:
  strategy:
    canary:
      # Reference to a Service which the controller will update to point to the canary ReplicaSet
      canaryService: rollouts-demo-canary
      # Reference to a Service which the controller will update to point to the stable ReplicaSet
      stableService: rollouts-demo-stable
      trafficRouting:
        nginx:
          # Reference to an Ingress which has a rule pointing to the stable service (e.g. rollouts-demo-stable)
          # This ingress will be cloned with a new name, in order to achieve NGINX traffic splitting.
          stableIngress: rollouts-demo-stable
        smi: {}

canary.trafficRouting.nginx.stableIngress에서 참조하는 Ingress에는 canary.stableService 아래에 참조된 Service를 백엔드로 가리키는 host 규칙이 있어야 합니다. 우리 예제에서 그 stable Service는 rollouts-demo-stable입니다:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: rollouts-demo-stable
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: rollouts-demo.local
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            # Reference to a Service name, also specified in the Rollout spec.strategy.canary.stableService field
            name: rollouts-demo-stable
            port:
              number: 80

다음 명령어를 실행해 배포합니다:

  • Linkerd의 linkerd.io/inject: enabled 어노테이션이 있는 Rollout
  • 두 개의 Service (stable 및 canary)
  • 하나의 Ingress
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/mixed/rollout.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/mixed/services.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/mixed/ingress.yaml

매니페스트를 적용한 뒤 클러스터에서 다음 rollout, services, ingress 리소스를 볼 수 있어야 합니다:

$ kubectl get ro
NAME            DESIRED   CURRENT   UP-TO-DATE   AVAILABLE
rollouts-demo   1         2         1            2

$ kubectl get svc
NAME                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
rollouts-demo-canary   ClusterIP   10.111.69.188    <none>        80/TCP    23m
rollouts-demo-stable   ClusterIP   10.109.175.248   <none>        80/TCP    23m

$ kubectl get ing
NAME                   CLASS    HOSTS                 ADDRESS        PORTS   AGE
rollouts-demo-stable   <none>   rollouts-demo.local   192.168.64.2   80      23m

또한 rollout이 자동으로 생성하고 소유하는 TrafficSplit 리소스도 볼 수 있어야 합니다:

$ kubectl get trafficsplit
NAME            SERVICE
rollouts-demo   rollouts-demo-stable

생성된 TrafficSplit 리소스를 조사하면 가중치가 자동으로 구성되어 트래픽의 100%를 rollouts-demo-stable 서비스로, 0%를 rollouts-demo-canary로 보내는 것을 확인할 수 있습니다. 이 값들은 업데이트 중에 갱신됩니다.

apiVersion: split.smi-spec.io/v1alpha1
kind: TrafficSplit
metadata:
  name: rollouts-demo
  namespace: default
spec:
  backends:
  - service: rollouts-demo-canary
    weight: "0"
  - service: rollouts-demo-stable
    weight: "100"
  service: rollouts-demo-stable

또한 rollouts 컨트롤러가 생성한 두 번째 ingress인 rollouts-demo-rollouts-demo-stable-canary도 확인할 수 있습니다. 이 ingress가 "canary ingress"이며, nginx.stableIngress 아래에 참조된 사용자 관리 Ingress의 클론입니다. nginx ingress controller가 canary 트래픽 분할을 달성하기 위해 사용합니다. 생성된 ingress의 이름은 <ROLLOUT-NAME>-<INGRESS-NAME>-canary 형식으로 만들어집니다. 두 번째 Ingress에 대한 자세한 내용은 다음 섹션에서 다룹니다.

2. 업데이트 수행 (Perform an update)

이제 이미지를 변경해 rollout을 업데이트하고, 일시 중지 상태에 도달할 때까지 기다립니다.

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로, 95%가 stable로 향합니다. 컨트롤러가 생성한 TrafficSplit을 조사하면 가중치가 canary 배포의 현재 setWeight: 5 단계를 반영하도록 갱신된 것을 볼 수 있습니다.

apiVersion: split.smi-spec.io/v1alpha1
kind: TrafficSplit
metadata:
  name: rollouts-demo
  namespace: default
spec:
  backends:
  - service: rollouts-demo-canary
    weight: "5"
  - service: rollouts-demo-stable
    weight: "95"
  service: rollouts-demo-stable

rollout 컨트롤러가 생성한 Ingress 복사본을 조사하면 원본 ingress에 비해 다음 변경 사항이 있음을 볼 수 있습니다:

  • 어노테이션에 두 개의 추가 NGINX 특정 canary 어노테이션이 추가됩니다.
  • Ingress 규칙에는 백엔드를 canary 서비스로 가리키는 규칙이 있습니다.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: rollouts-demo-rollouts-demo-stable-canary
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/canary: "true"
    nginx.ingress.kubernetes.io/canary-weight: "5"
spec:
  rules:
  - host: rollouts-demo.local
    http:
      paths:
      - backend:
          serviceName: rollouts-demo-canary
          servicePort: 80

Rollout이 단계를 진행함에 따라 TrafficSplit 및 Ingress 리소스의 가중치는 단계의 현재 setWeight와 일치하도록 조정됩니다.

더 알아보기 (Learn more)

  • 기본 시작 가이드에서 배우는 카나리/블루-그린 배포
  • SMI(Service Mesh Interface)와 Linkerd 통합
  • NGINX Ingress Controller를 통한 canary 트래픽 분할
  • Istio 등 다른 트래픽 라우터와의 다중 공급자 구성