Argo Rollouts로 점진적 롤아웃
Argo Rollouts로 점진적 롤아웃
이 페이지에서는 Argo Rollouts Controller를 Consul on Kubernetes와 함께 구성하고 사용하여 Canary 배포를 위한 고급 하위 집합 기반 라우팅을 관리하는 과정을 설명해요. Consul의 Argo Rollouts 지원은 현재 하위 집합 기반 라우팅으로 제한된답니다.
출처: 문서
본문
이 페이지에서는 Argo Rollouts Controller를 Consul on Kubernetes와 함께 구성하고 사용하여 Canary 배포를 위한 고급 하위 집합 기반(subset-based) 라우팅을 관리하는 과정을 설명합니다.
Consul의 Argo Rollouts 지원은 현재 하위 집합 기반 라우팅으로 제한됩니다.
Argo Rollouts Controller 설치
Consul on Kubernetes와 함께 Argo Rollouts Controller를 설치하는 방법은 세 가지입니다.
- Helm과 init 컨테이너를 사용한 Rollouts 설치. 이 방법으로 Argo Rollouts Controllor를 설치하는 것을 권장합니다.
- Helm과 바이너리를 사용한 Rollouts 설치
- 독립형 설치
컨트롤러를 설치한 후에는 Kubernetes 클러스터에 RBAC CRD를 적용해야 합니다.
Helm과 init 컨테이너를 사용한 Rollouts 설치
이 플러그인을 설치할 때 이 방법을 사용하는 것이 좋습니다.
플러그인을 구성하려면 values.yaml 파일에 다음 코드를 추가하세요.
controller:
initContainers:
- name: copy-consul-plugin
image: hashicorp/rollouts-plugin-trafficrouter-consul
command: ["/bin/sh", "-c"]
args:
# Copy the binary from the image to the rollout container
- cp /bin/rollouts-plugin-trafficrouter-consul /plugin-bin/hashicorp
volumeMounts:
- name: consul-plugin
mountPath: /plugin-bin/hashicorp
trafficRouterPlugins:
trafficRouterPlugins: |-
- name: "hashicorp/consul"
location: "file:///plugin-bin/hashicorp/rollouts-plugin-trafficrouter-consul"
volumes:
- name: consul-plugin
emptyDir: {}
volumeMounts:
- name: consul-plugin
mountPath: /plugin-bin/hashicorp
그런 다음 Helm을 사용해 argo-rollouts를 설치하고 업데이트된 values를 적용하세요.
$ helm install argo-rollouts argo/argo-rollouts -f values.yaml -n argo-rollouts
Helm과 바이너리를 사용한 Rollouts 설치
바이너리를 빌드하고 Rollouts를 설치하려면 다음 단계를 완료하세요.
- 선호하는 도구로 이 플러그인을 빌드합니다. 예:
make build. - 빌드된 플러그인을
argo-rollouts컨테이너에 마운트합니다. - 플러그인을 구성하려면
values.yaml파일에 다음 코드를 추가합니다.
controller:
trafficRouterPlugins:
trafficRouterPlugins: |-
- name: "argoproj-labs/consul"
location: "file:///plugin-bin/hashicorp/rollouts-plugin-trafficrouter-consul"
volumes:
- name: consul-route-plugin
hostPath:
# The path being mounted to, change this depending on your mount path
path: /rollouts-plugin-trafficrouter-consul
type: DirectoryOrCreate
volumeMounts:
- name: consul-route-plugin
mountPath: /plugin-bin/hashicorp
그런 다음 Helm을 사용해 argo-rollouts를 설치하고 업데이트된 values를 적용하세요.
$ helm install argo-rollouts argo/argo-rollouts -f values.yaml -n argo-rollouts
독립형 설치 (Stand-alone installation)
이 섹션에서는 독립형 설치를 만드는 과정을 설명합니다. 이 지침은 예시 목적입니다. 이 플러그인을 만들고 설치할 때는 init 컨테이너를 사용하는 것이 좋습니다.
Rollouts 플러그인의 독립형 설치를 만들려면 다음 단계를 완료하세요.
- 이 플러그인을 빌드합니다.
- 플러그인을 경로에 두고
argo-rollouts컨테이너에 마운트합니다. - 플러그인의 위치로
argo-rollouts를 구성하는ConfigMap을 만듭니다.
다음 예시는 Deployment를 예약하고 이를 argo-rollouts 컨테이너에 마운트합니다.
apiVersion: apps/v1
kind: Deployment
metadata:
name: argo-rollouts
namespace: argo-rollouts
spec:
selector:
matchLabels:
app.kubernetes.io/name: argo-rollouts
template:
spec:
# ...
volumes:
# ...
- name: consul-plugin
hostPath:
path: /plugin-bin/hashicorp/rollouts-plugin-trafficrouter-consul
type: DirectoryOrCreate
containers:
- name: argo-rollouts
# ...
volumeMounts:
- name: consul-route-plugin
mountPath: /plugin-bin/hashicorp
다음 예시는 플러그인의 위치로 ConfigMap을 만듭니다.
apiVersion: v1
kind: ConfigMap
metadata:
name: argo-rollouts-config
namespace: argo-rollouts
data:
trafficRouterPlugins: |-
- name: "argoproj-labs/consul"
location: "file:///plugin-bin/hashicorp/rollouts-plugin-trafficrouter-consul"
binaryData: {}
RBAC 설치
바이너리를 마운트하거나 init 컨테이너를 사용한 후 Argo Rollout Consul plugin rbac.yaml을 사용해 RBAC를 구성하세요.
$ kubectl apply -f https://raw.githubusercontent.com/argoproj-labs/rollouts-plugin-trafficrouter-consul/main/yaml/rbac.yaml
Argo Rollouts Consul 플러그인 사용
롤아웃되는 서비스가 사용하는 Kubernetes Service를 예약합니다. 또한 서비스에 필요한 service defaults와 proxy defaults를 구성하세요.
apiVersion: v1
kind: Service
metadata:
name: test-service
spec:
selector:
app: test-service
ports:
- name: http
port: 80
targetPort: 8080
다음으로 안정(stable) 서비스에 대한 service resolver와 service splitter CRD를 만듭니다. Argo는 canary 배포 중에 이러한 CRD를 자동으로 수정합니다.
다음 예시는 서비스 하위 집합을 만들고 안정 하위 집합을 기본값으로 설정하는 service resolver CRD의 구성을 보여줍니다.
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceResolver
metadata:
name: test-service
spec:
subsets:
stable:
filter: Service.Meta.version == 1
canary:
filter: ""
defaultSubset: stable
다음 예시는 초기에 트래픽의 100%를 안정 배포로 보내는 service splitter CRD의 구성을 보여줍니다.
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceSplitter
metadata:
name: test-service
spec:
splits:
- weight: 100
serviceSubset: stable
- weight: 0
serviceSubset: canary
그런 다음 Argo Rollout 리소스를 구성하여 canary 배포를 점진적으로 롤아웃합니다.
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: test-service
spec:
replicas: 3
selector:
matchLabels:
app: test-service
template:
metadata:
labels:
app: test-service
annotations:
consul.hashicorp.com/connect-inject: "true"
consul.hashicorp.com/service-meta-version: "1"
consul.hashicorp.com/service-tags: "v1"
spec:
containers:
- name: test-service
# Using alpine vs latest as there is a build issue with M1s. Also other tests in multiport-app reference
# alpine so standardizing this.
image: docker.mirror.hashicorp.services/hashicorp/http-echo:alpine
args:
- -text="I am v1"
- -listen=:8080
ports:
- containerPort: 8080
name: http
serviceAccountName: test-service
terminationGracePeriodSeconds: 0 # so deletion is quick
strategy:
canary:
trafficRouting:
plugins:
hashicorp/consul:
stableSubsetName: stable # subset name of the stable service
canarySubsetName: canary # subset name of the canary service
serviceName: test-service
steps:
- setWeight: 20
- pause: {}
- setWeight: 40
- pause: {duration: 10}
- setWeight: 60
- pause: {duration: 10}
- setWeight: 80
- pause: {duration: 10}
마지막으로 Argo Rollouts Kubectl 플러그인으로 Rollout 작업을 수행합니다.
$ kubectl argo rollouts promote test-service