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

Argo Rollouts와 Ambassador 시작하기 (Quick Start)

원문 보기 위키 갱신

이 튜토리얼은 canary 릴리스를 가능하게 하기 위해 Argo Rollouts를 Ambassador와 함께 동작하도록 구성하는 과정을 안내해요. 이 가이드에서 사용하는 모든 파일은 이 저장소의 examples 디렉토리에서 확인할 수 있어요.

출처: 문서

본문

이 튜토리얼은 canary 릴리스를 가능하게 하기 위해 Argo Rollouts를 Ambassador와 함께 동작하도록 구성하는 과정을 안내해요. 이 가이드에서 사용하는 모든 파일은 이 저장소의 examples 디렉토리에서 확인할 수 있어요.

Requirements

  • Kubernetes 클러스터

  • 클러스터에 Argo-Rollouts 설치

Note Ambassador Edge Stack 또는 Emissary-ingress 2.0+를 사용하는 경우, Argo-Rollouts 버전 v1.1+를 설치하고 argo-rollouts 배포에 --ambassador-api-version getambassador.io/v3alpha1을 제공해야 해요.

1. Install and configure Ambassador Edge Stack

클러스터에 Ambassador가 없다면 Edge Stack 문서를 따라 설치할 수 있어요.

기본적으로 Edge Stack은 Kubernetes 서비스를 통해 라우팅해요. canary에서 최상의 성능을 얻으려면 endpoint routing 사용을 권장해요. resolver.yaml이라는 파일에 다음 구성을 저장해 클러스터에서 endpoint routing을 활성화해요:

apiVersion: getambassador.io/v2
kind: KubernetesEndpointResolver
metadata:
  name: endpoint

이 구성을 클러스터에 적용해요: kubectl apply -f resolver.yaml.

2. Create the Kubernetes Services

echo-stable과 echo-canary라는 두 개의 Kubernetes 서비스를 만들 거예요. 이 구성을 echo-service.yaml 파일에 저장해요.

apiVersion: v1
kind: Service
metadata:
  labels:
    app: echo
  name: echo-stable
spec:
  type: ClusterIP
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app: echo
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: echo
  name: echo-canary
spec:
  type: ClusterIP
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app: echo

또한 서비스로 가는 Edge Stack 라우트를 만들 거예요. 다음 구성을 echo-mapping.yaml 파일에 저장해요.

apiVersion: getambassador.io/v2
kind:  Mapping
metadata:
  name:  echo
spec:
  prefix: /echo
  rewrite: /echo
  service: echo-stable:80
  resolver: endpoint

이 두 구성을 Kubernetes 클러스터에 적용해요:

kubectl apply -f echo-service.yaml
kubectl apply -f echo-mapping.yaml

3. Deploy the Echo Service

Rollout 리소스를 만들고 rollout.yaml 파일에 저장해요. Argo가 라우팅에 Ambassador Edge Stack을 사용하도록 지시하는 trafficRouting 속성에 주목해요.

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: echo-rollout
spec:
  selector:
    matchLabels:
      app: echo
  template:
    metadata:
      labels:
        app: echo
    spec:
      containers:
        - image: hashicorp/http-echo
          args:
            - "-text=VERSION 1"
            - -listen=:8080
          imagePullPolicy: Always
          name: echo-v1
          ports:
            - containerPort: 8080
  strategy:
    canary:
      stableService: echo-stable
      canaryService: echo-canary
      trafficRouting:
        ambassador:
          mappings:
            - echo
      steps:
      - setWeight: 30
      - pause: {duration: 30s}
      - setWeight: 60
      - pause: {duration: 30s}
      - setWeight: 100
      - pause: {duration: 10}

클러스터에 rollout을 적용해요: kubectl apply -f rollout.yaml. 서비스의 첫 번째 버전을 배포하는 것이므로 canary rollout은 발생하지 않는 점에 주의해요.

4. Test the service

이제 이 rollout이 예상대로 동작하는지 테스트해 볼게요. 새 터미널 창을 엽니다. 클러스터에 요청을 보내는 데 사용할 거예요. Edge Stack의 외부 IP 주소를 가져와요:

export AMBASSADOR_LB_ENDPOINT=$(kubectl -n ambassador get svc ambassador -o "go-template={{range .status.loadBalancer.ingress}}{{or .ip .hostname}}{{end}}")

echo 서비스에 요청을 보내요:

curl -Lk "https://$AMBASSADOR_LB_ENDPOINT/echo/"

"VERSION 1"이라는 응답을 받아야 해요.

5. Rollout a new version

이제 서비스의 새 버전을 롤아웃할 시간이에요. rollout.yaml의 echo 컨테이너를 "VERSION 2"를 표시하도록 업데이트해요:

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: echo-rollout
spec:
  selector:
    matchLabels:
      app: echo
  template:
    metadata:
      labels:
        app: echo
    spec:
      containers:
        - image: hashicorp/http-echo
          args:
            - "-text=VERSION 2"
            - -listen=:8080
          imagePullPolicy: Always
          name: echo-v1
          ports:
            - containerPort: 8080
  strategy:
    canary:
      stableService: echo-stable
      canaryService: echo-canary
      trafficRouting:
        ambassador:
          mappings:
            - echo
      steps:
      - setWeight: 30
      - pause: {duration: 30s}
      - setWeight: 60
      - pause: {duration: 30s}
      - setWeight: 100
      - pause: {duration: 10}

kubectl apply -f rollout.yaml을 입력해 rollout을 클러스터에 적용해요. 그러면 트래픽의 30%를 30초 동안 서비스로 라우팅하고, 이어서 60%를 다시 30초 동안 라우팅하며 서비스 2 버전을 롤아웃해요.

명령줄에서 rollout 상태를 모니터링할 수 있어요:

kubectl argo rollouts get rollout echo-rollout --watch

다음과 유사한 출력이 표시돼요:

Name:            echo-rollout
Namespace:       default
Status:          ॥ Paused
Message:         CanaryPauseStep
Strategy:        Canary
  Step:          1/6
  SetWeight:     30
  ActualWeight:  30
Images:          hashicorp/http-echo (canary, stable)
Replicas:
  Desired:       1
  Current:       2
  Updated:       1
  Ready:         2
  Available:     2

NAME                                      KIND        STATUS        AGE    INFO
⟳ echo-rollout                            Rollout     ॥ Paused      2d21h
├──# revision:3
│  └──⧉ echo-rollout-64fb847897           ReplicaSet  ✔ Healthy     2s     canary
│     └──□ echo-rollout-64fb847897-49sg6  Pod         ✔ Running     2s     ready:1/1
├──# revision:2
│  └──⧉ echo-rollout-578bfdb4b8           ReplicaSet  ✔ Healthy     3h5m   stable
│     └──□ echo-rollout-578bfdb4b8-86z6n  Pod         ✔ Running     3h5m   ready:1/1
└──# revision:1
   └──⧉ echo-rollout-948d9c9f9            ReplicaSet  • ScaledDown  2d21h

다른 터미널 창에서 루프로 요청을 보내 canary가 제대로 진행되는지 확인할 수 있어요:

while true; do curl -k https://$AMBASSADOR_LB_ENDPOINT/echo/; sleep 0.2; done

그러면 VERSION 1 문자열에서 VERSION 2 문자열로 점진적으로 전환되는 서비스의 응답 목록이 표시돼요.

Ambassador와 Argo-Rollouts 통합에 대한 자세한 내용은 Ambassador Argo 문서를 참고해요.

더 알아보기 (Learn more)