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

시작하기 - Istio (Getting Started - Istio)

원문 보기 위키 갱신

이 가이드는 Argo Rollouts가 Istio Service Mesh와 연동해 트래픽 셰이핑(traffic shaping)을 수행하는 방법을 다룹니다. 기본 시작 가이드의 개념을 바탕으로 하므로, Canary 배포의 기본 흐름을 먼저 익히고 나면 더 이해하기 쉬워요.

출처: Argo Rollouts 문서

본문

이 가이드는 Argo Rollouts가 트래픽 셰이핑을 위해 Istio Service Mesh와 통합하는 방법을 다룹니다. 이 가이드는 기본 시작 가이드의 개념을 바탕으로 합니다.

요구 사항 (Requirements)

  • Istio가 설치된 Kubernetes 클러스터

Tip

Istio 환경 구성 방법은 Istio용 환경 설정 가이드를 참조해 Istio가 있는 로컬 minikube 환경을 설정하세요.

1. Rollout, 서비스, Istio VirtualService, Istio Gateway 배포

Istio가 트래픽 라우터로 사용될 때, Rollout canary 전략은 다음 필수 필드를 정의해야 합니다.

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollouts-demo
spec:
  strategy:
    canary:
      # Reference to a Service which the controller updates to point to the canary ReplicaSet
      canaryService: rollouts-demo-canary
      # Reference to a Service which the controller updates to point to the stable ReplicaSet
      stableService: rollouts-demo-stable
      trafficRouting:
        istio:
          virtualServices:
          # One or more virtualServices can be configured
          # Reference to a VirtualService which the controller updates with canary weights
          - name: rollouts-demo-vsvc1
            # Optional if there is a single HTTP route in the VirtualService, otherwise required
            routes:
            - http-primary
            # Optional if there is a single HTTPS/TLS route in the VirtualService, otherwise required
            tlsRoutes:
            # Below fields are optional but if defined, they should match exactly with at least one of the TLS route match rules in your VirtualService
            - port: 443 # Only required if you want to match any rule in your VirtualService which contains this port
              # Only required if you want to match any rule in your VirtualService which contain all these SNI hosts
              sniHosts:
              - reviews.bookinfo.com
              - localhost
          - name: rollouts-demo-vsvc2
            # Optional if there is a single HTTP route in the VirtualService, otherwise required
            routes:
              - http-secondary
            # Optional if there is a single HTTPS/TLS route in the VirtualService, otherwise required
            tlsRoutes:
              # Below fields are optional but if defined, they should match exactly with at least one of the TLS route match rules in your VirtualService
              - port: 443 # Only required if you want to match any rule in your VirtualService which contains this port
                # Only required if you want to match any rule in your VirtualService which contain all these SNI hosts
                sniHosts:
                  - reviews.bookinfo.com
                  - localhost
            tcpRoutes:
              # Below fields are optional but if defined, they should match exactly with at least one of the TCP route match rules in your VirtualService
              - port: 8020 # Only required if you want to match any rule in your VirtualService which contains this port

trafficRouting.istio.virtualService 또는 trafficRouting.istio.virtualServices에 참조되는 VirtualService와 라우트. trafficRouting.istio.virtualServices는 단일 virtualService만 추가할 수 있는 trafficRouting.istio.virtualService와 달리 하나 이상의 virtualService를 추가하는 데 도움이 됩니다. 이는 rollout에 참조된 stable 서비스와 canary 서비스 간에 분할되는 HTTP, TLS, TCP 또는 혼합 라우트 사양을 갖는 데 필요합니다. 라우트가 HTTPS/TLS인 경우 주어진 포트 번호 및/또는 SNI 호스트로 일치시킬 수 있습니다. 둘 다 선택 사항이며, 이를 포함하는 VirtualService의 규칙과 일치시키려는 경우에만 필요합니다. 이 가이드에서 두 서비스는 각각 rollouts-demo-stable과 rollouts-demo-canary입니다. 이 두 서비스의 가중치는 처음에는 stable 서비스에 100%, canary 서비스에 0%로 설정되어야 합니다. 업데이트 중에는 이 값들이 컨트롤러에 의해 수정됩니다. VirtualService가 여러 개인 경우, 각 VirtualService의 stable 및 canary 서비스의 가중치 값이 컨트롤러에 의해 동시에 수정됩니다. rollout 사양에 HTTP와 HTTPS 라우트가 모두 있고 VirtualService 사양과 일치하므로, 이 두 라우트 모두에 대해 가중치가 수정된다는 점에 유의하세요.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: rollouts-demo-vsvc1
spec:
  gateways:
  - rollouts-demo-gateway
  hosts:
  - rollouts-demo-vsvc1.local
  http:
  - name: http-primary  # Should match rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.routes
    route:
    - destination:
        host: rollouts-demo-stable  # Should match rollout.spec.strategy.canary.stableService
        port:
          number: 15372
      weight: 100
    - destination:
        host: rollouts-demo-canary  # Should match rollout.spec.strategy.canary.canaryService
        port:
          number: 15372
      weight: 0
  tls:
  - match:
    - port: 443  # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
      sniHosts: # Should match all the SNI hosts of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
      - reviews.bookinfo.com
      - localhost
    route:
    - destination:
        host: rollouts-demo-stable  # Should match rollout.spec.strategy.canary.stableService
      weight: 100
    - destination:
        host: rollouts-demo-canary  # Should match rollout.spec.strategy.canary.canaryService
      weight: 0
  tcp:
  - match:
      - port: 8020 # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tcpRoutes
    route:
    - destination:
        host: rollouts-demo-stable # Should match rollout.spec.strategy.canary.stableService
      weight: 100
    - destination:
        host: rollouts-demo-canary # Should match rollout.spec.strategy.canary.canaryService
      weight: 0
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: rollouts-demo-vsvc2
spec:
  gateways:
  - rollouts-demo-gateway
  hosts:
  - rollouts-demo-vsvc2.local
  http:
  - name: http-secondary  # Should match rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.routes
    route:
    - destination:
        host: rollouts-demo-stable  # Should match rollout.spec.strategy.canary.stableService
        port:
          number: 15373
      weight: 100
    - destination:
        host: rollouts-demo-canary  # Should match rollout.spec.strategy.canary.canaryService
        port:
          number: 15373
      weight: 0
  tls:
  - match:
    - port: 443  # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
      sniHosts: # Should match all the SNI hosts of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
      - reviews.bookinfo.com
    route:
    - destination:
        host: rollouts-demo-stable  # Should match rollout.spec.strategy.canary.stableService
      weight: 100
    - destination:
        host: rollouts-demo-canary  # Should match rollout.spec.strategy.canary.canaryService
      weight: 0
  tcp:
  - match:
    - port: 8020  # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tcpRoutes
    route:
    - destination:
        host: rollouts-demo-stable  # Should match rollout.spec.strategy.canary.stableService
      weight: 100
    - destination:
        host: rollouts-demo-canary  # Should match rollout.spec.strategy.canary.canaryService
      weight: 0

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

  • Rollout
  • 두 서비스 (stable 및 canary)
  • 하나 이상의 Istio VirtualService
  • Istio Gateway
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/rollout.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/services.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/multipleVirtualsvc.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/gateway.yaml

매니페스트를 적용한 후 클러스터에 다음과 같은 rollout, 서비스, virtualservice, gateway 리소스가 보여야 합니다.

$ 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-canary   ClusterIP   10.103.146.137   <none>        80/TCP    37s
rollouts-demo-stable   ClusterIP   10.101.158.227   <none>        80/TCP    37s

$ kubectl get virtualservice
NAME                  GATEWAYS                  HOSTS                         AGE
rollouts-demo-vsvc1   [rollouts-demo-gateway]   [rollouts-demo-vsvc1.local]   54s
rollouts-demo-vsvc2   [rollouts-demo-gateway]   [rollouts-demo-vsvc2.local]   54s

$ kubectl get gateway
NAME                    AGE
rollouts-demo-gateway   71s
kubectl argo rollouts get rollout rollouts-demo

![IMAGE] Rollout Istio

2. 업데이트 수행

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

kubectl argo rollouts set image rollouts-demo rollouts-demo=argoproj/rollouts-demo:yellow
kubectl argo rollouts get rollout rollouts-demo

![IMAGE] Rollout Istio Paused

이 시점에서 Rollout의 canary 버전과 stable 버전이 모두 실행 중이며, 트래픽의 5%가 canary로 전달됩니다. 이것이 어떻게 작동하는지 이해하려면 Rollout이 참조하던 VirtualService를 검사해 보세요. 두 VirtualService를 살펴보면 컨트롤러가 canary의 현재 가중치를 반영하도록 라우트 대상 가중치를 수정한 것을 확인할 수 있습니다.

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: rollouts-demo-vsvc1
  namespace: default
spec:
  gateways:
  - rollouts-demo-gateway
  hosts:
  - rollouts-demo-vsvc1.local
  http:
  - name: http-primary
    route:
    - destination:
        host: rollouts-demo-stable
        port:
          number: 15372
      weight: 95
    - destination:
        host: rollouts-demo-canary
        port:
          number: 15372
      weight: 5
  tls:
  - match:
    - port: 443
      sniHosts:
      - reviews.bookinfo.com
      - localhost
    route:
    - destination:
        host: rollouts-demo-stable
      weight: 95
    - destination:
        host: rollouts-demo-canary
      weight: 5
  tcp:
  - match:
    - port: 8020
    route:
    - destination:
        host: rollouts-demo-stable
      weight: 95
    - destination:
        host: rollouts-demo-canary
      weight: 5
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: rollouts-demo-vsvc2
  namespace: default
spec:
  gateways:
  - rollouts-demo-gateway
  hosts:
  - rollouts-demo-vsvc2.local
  http:
  - name: http-primary
    route:
    - destination:
        host: rollouts-demo-stable
        port:
          number: 15373
      weight: 95
    - destination:
        host: rollouts-demo-canary
        port:
          number: 15373
      weight: 5
  tls:
  - match:
    - port: 443
      sniHosts:
      - reviews.bookinfo.com
    route:
    - destination:
        host: rollouts-demo-stable
      weight: 95
    - destination:
        host: rollouts-demo-canary
      weight: 5
  tcp:
  - match:
    - port: 8020
    route:
    - destination:
        host: rollouts-demo-stable
      weight: 95
    - destination:
        host: rollouts-demo-canary
      weight: 5

Rollout이 step들을 진행하면서 HTTP, TLS 및/또는 TCP 라우트 대상 가중치는 step의 현재 setWeight와 일치하도록 조정됩니다.

더 알아보기 (Learn more)

  • Argo Rollouts Canary 배포 전략의 기본 개념
  • Argo Rollouts 트래픽 관리(Traffic Management) 개요
  • Nginx Ingress Controller를 통한 트래픽 라우팅
  • set image 명령으로 이미지 업데이트하기