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

시작하기 - 여러 Provider (Service Mesh Interface와 NGiNX Ingress)

원문 보기 위키 갱신

이 가이드는 Argo Rollouts가 여러 TrafficRouting과 어떻게 통합되는지 설명해요. 예시로 Linkerd와 NGINX Ingress Controller를 사용해 트래픽 셰이핑을 하지만, 기존 trafficRouting 옵션 사이의 다른 조합도 만들 수 있어요.

출처: 문서

본문

Important

v1.2부터 사용할 수 있어요.

이 가이드는 Argo Rollouts가 여러 TrafficRouting과 어떻게 통합되는지 설명해요. Linkerd와 NGINX Ingress Controller를 사용해 트래픽 셰이핑을 하지만, 기존 trafficRouting 옵션 사이의 다른 조합도 만들 수 있어요.

이 가이드는 기본 시작하기 가이드, NGINX 가이드, SMI 가이드의 개념을 바탕으로 진행해요.

Requirements

  • Linkerd가 설치된 Kubernetes 클러스터

  • NGINX ingress controller가 설치되고 메시에 포함된 Kubernetes 클러스터

Tip

linkerd와 nginx를 사용해 로컬 minikube 환경을 설정하는 방법은 environment setup guide for linkerd를 참고해요.

1. Deploy the Rollout, Services, and 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 annotation이 있는 Rollout

  • 두 개의 서비스 (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 리소스를 살펴보면, 가중치가 자동으로 rollouts-demo-stable 서비스에 100% 트래픽, rollouts-demo-canary에 0% 트래픽을 보내도록 구성돼 있어요. 이 값들은 업데이트 중에 갱신돼요.

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는 nginx.stableIngress 아래에서 참조하는 사용자 관리 Ingress의 복제본인 "canary ingress"예요. nginx ingress controller가 canary 트래픽 분할을 달성하는 데 사용되죠. 생성된 ingress의 이름은 <ROLLOUT-NAME>-<INGRESS-NAME>-canary 형식으로 만들어진답니다. 두 번째 Ingress에 대한 자세한 내용은 다음 섹션에서 다뤄요.

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로, 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 annotation이 annotations에 추가돼요.

  • Ingress rules에 백엔드를 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이 steps를 진행하면서 TrafficSplit과 Ingress 리소스의 가중치가 steps의 현재 setWeight와 일치하도록 조정돼요.

더 알아보기 (Learn more)