Rollouts 리소스 플러그인 (Resource Plugin for Rollouts)
이 문서는 Argo Rollouts를 확장하여 Deployment 외의 다양한 쿠버네티스 리소스 유형(초점은 StatefulSets)에 대해 고급 배포 전략(canary 및 blue/green)을 지원하기 위한 플러그인 기반 아키텍처를 제안합니다. 새로운 전용 RolloutPlugin Controller가 새 CRD를 관리하는 방식의 설계안을 상세히 설명해 드립니다.
출처: Argo Rollouts 문서
본문
이 문서는 Deployment를 넘어 다양한 쿠버네티스 리소스 유형(초점은 StatefulSets)에 대해 고급 배포 전략(canary 및 blue/green)을 지원하도록 Argo Rollouts를 확장하는 플러그인 기반 아키텍처를 제안합니다.
요약 (Summary)
현재 Argo Rollouts는 내부적으로 ReplicaSet을 관리하는 Deployment 워크로드 유형만 지원합니다. 이 제안은 새로운 전용 RolloutPlugin Controller가 새 CRD를 관리하는 플러그인 아키텍처를 통해 다른 쿠버네티스 리소스도 지원하도록 Argo Rollouts를 확장하는 것을 목표로 합니다.
이 접근 방식은 기존 컨트롤러와의 깔끔한 분리를 만들어 리소스별 최적화를 가능하게 하면서, 커뮤니티가 추가 리소스 유형에 대해 확장할 수 있는 프레임워크를 제공합니다.
동기 (Motivation)
현재 Rollouts 컨트롤러는 ReplicaSet에 밀접하게 결합되어 있어 Deployment 워크로드만 지원하도록 제한됩니다. 많은 사용자가 StatefulSets, DaemonSets, 그리고 잠재적으로 커스텀 리소스와 같은 다른 워크로드 유형에 대해 canary 또는 blue-green 업그레이드를 수행해야 합니다. 플러그인 아키텍처를 구현하면 각 새 리소스에 대해 컨트롤러를 크게 재작성할 필요 없이 이러한 리소스 유형을 지원할 수 있습니다.
StatefulSet은 상태 저장(stateful) 애플리케이션 배포에서 널리 사용되므로 강력한 초기 사용 사례를 제공합니다. StatefulSet의 네이티브 업데이트 기능은 기본 롤링 업데이트와 선택적인 partition 기반 업데이트로 제한되며, 다음을 지원하지 않습니다.
- 업데이트 중 제어된 트래픽 분산
- 업데이트의 자동 분석 및 검증
- 점진적 트래픽 전환
- 자동화된 canary 분석
- 즉시 롤백 기능을 갖춘 Blue/green 배포
목표 (Goals)
- 모든 쿠버네티스 리소스 유형에서 작동할 수 있는 플러그인 아키텍처 정의
- 핵심 롤아웃 기능을 유지하면서 리소스별 세부 사항을 추상화하는 인터페이스 생성
- 초기 구현으로 StatefulSet에 대한 canary 및 blue/green 배포 지원
- 기존 Argo Rollouts 기능과의 호환성 유지
- 커뮤니티가 추가 리소스 유형으로 확장할 수 있는 프레임워크 제공
비목표 (Non-Goals)
- 어떤 리소스 유형에 대해서도 핵심 쿠버네티스 컨트롤러 수정
- 이 제안 내에서 가능한 모든 리소스 유형 구현
- 네이티브로 지원하지 않는 리소스에 대한 in-place 업데이트 지원
- 모든 사용 사례를 내부적으로 처리하려는 모놀리식 솔루션 생성
제안된 구현: RolloutPlugin Controller
이 접근 방식은 RolloutPlugin이라는 새로운 CRD(커스텀 리소스 정의)를 관리하는 전용 컨트롤러를 만드는 것입니다. 이 컨트롤러는 기존 Argo Rollouts 컨트롤러와 완전히 분리되어 있어 깔끔한 분리와 리소스별 최적화를 제공합니다. 새 컨트롤러의 구현은 네이티브 informer 대신 controller-runtime 라이브러리를 사용하여 진행되며, 이 라이브러리는 그렇지 않으면 필요할 많은 보일러플레이트 코드를 추상화합니다.
트래픽 라우팅 및 확장 전략 (Traffic Routing and Scaling Strategy)
RolloutPlugin CRD와 컨트롤러는 트래픽 관리보다는 네이티브 리소스 기능(예: StatefulSet의 partition 필드)을 통한 점진적 전달에 중점을 둡니다.
핵심 결정 사항 (Key Decisions):
- setCanaryScale 필드 없음: 파드 수를 트래픽 라우팅과 결합하지 않기 위해, CRD는 기존 Rollout CRD에서 사용되는
setCanaryScale필드를 구현하지 않습니다. 이는 replica/pod 수의 개념을 트래픽 분산과 분리합니다. - 가중치 전용 접근 방식 (Weight-only approach): CRD는 롤아웃 진행을 제어하기 위해
setWeight단계만 사용합니다. StatefulSet의 경우 이는 트래픽 백분율이 아니라 partition 필드 조작(업데이트된 파드의 백분율)으로 변환됩니다. - 미래 플러그인 확장성 (Future plugin extensibility): 트래픽 라우팅은 초기 범위에 없지만, CRD와 플러그인 인터페이스는 개별 플러그인이 특정 리소스 유형에 필요할 때 향후 트래픽 라우팅 기능을 구현할 수 있도록 설계되었습니다. 이는 핵심 컨트롤러를 단순하게 유지하면서 향후 개선을 위한 유연성을 보장합니다.
예제: 10개 replica를 가진 StatefulSet에서 setWeight: 40은 partition: 6으로 설정하여 4개 파드(replica의 40%)를 업데이트한다는 뜻이지, 트래픽의 40%가 해당 파드로 간다는 뜻이 아닙니다.
RolloutPlugin CRD
RolloutPlugin CRD는 모든 쿠버네티스 리소스 유형의 롤아웃을 관리하기 위한 일반적인 인터페이스를 정의합니다.
리소스 지정을 위한 CRD 설계 옵션
RolloutPlugin CRD는 여러 쿠버네티스 리소스 유형(StatefulSets, DaemonSets 등)을 지원할 수 있을 만큼 일반적이어야 하므로, 사용자가 관리할 리소스를 지정하는 방법에는 세 가지 접근 방식이 있습니다.
옵션 1: CRD에 리소스 스펙 임베드
이 접근 방식은 각 가능한 리소스 유형에 대한 전체 스펙을 RolloutPlugin CRD에 직접 임베드합니다.
Example:
apiVersion: argorollouts.io/v1alpha1
kind: RolloutPlugin
metadata:
name: my-rollout
spec:
resourceType: StatefulSet
statefulSetSpec:
# Complete StatefulSet spec here
daemonSetSpec:
# Complete DaemonSet spec here (unused)
strategy:
# ...
장점 (Pros):
- 자체 포함: 모든 구성이 한 곳에, 외부 의존성 없음
- 버전 제어 친화적: 완전한 원하는 구성이 하나의 리소스에 캡처됨
- 초기 배포: 워크로드와 롤아웃 관리를 함께 생성 가능
단점 (Cons):
- CRD 복잡성: 여러 리소스 유형 스펙이 있는 매우 큰 CRD 스키마
- 유지보수 부담: CRD를 상류 쿠버네티스 리소스 정의와 동기화 유지 필요
- 마이그레이션 어려움: 기존 워크로드를 재생성하거나 스펙을 복사해야 함
옵션 2: 기존 쿠버네티스 객체 참조 (권장)
이 접근 방식은 workloadRef를 사용하여 이름과 네임스페이스로 이미 생성된 쿠버네티스 리소스를 참조합니다.
Example:
apiVersion: argorollouts.io/v1alpha1
kind: RolloutPlugin
metadata:
name: my-rollout
spec:
workloadRef:
apiVersion: apps/v1
kind: StatefulSet
name: my-statefulset
namespace: default
strategy:
# ...
장점 (Pros):
- 단순한 CRD: 참조 필드만 필요한 최소 CRD 스키마
- 관심사 분리: 워크로드 정의가 롤아웃 전략과 분리됨
- 기존 리소스와 작동: 기존 워크로드를 재생성하지 않고 롤아웃 기능 추가 가능
- 표준 쿠버네티스 패턴: HPA가 Deployment를 참조하고 Rollout이 Deployment를 참조하는 기존 패턴을 따름
- 더 쉬운 유지보수: CRD를 쿠버네티스 리소스 스키마와 동기화할 필요 없음
- 명확한 소유권: 원래 리소스가 워크로드 스펙의 근원(source of truth)으로 남음
단점 (Cons):
- 2단계 프로세스: 먼저 워크로드를 생성한 다음 RolloutPlugin을 생성해야 함
- 조정 복잡성: 워크로드 스펙 업데이트를 롤아웃 전략과 조정해야 함
옵션 3: 리소스 유형별 전용 CRD 생성
이 접근 방식은 각 리소스 유형에 대해 별도의 CRD(StatefulSetRollout, DaemonSetRollout 등)를 생성합니다.
Example:
apiVersion: argorollouts.io/v1alpha1
kind: StatefulSetRollout
metadata:
name: my-sts-rollout
spec:
statefulSetSpec:
# StatefulSet specific fields
strategy:
# Rollout strategy
장점 (Pros):
- 타입 안전성: 각 CRD가 특정 리소스에 대해 강하게 타입화됨
- 독립적 진화: 각 CRD가 독립적으로 진화 가능
- 리소스별 기능: 리소스별 롤아웃 기능 추가가 쉬움
단점 (Cons):
- 유지보수 부담: 설치 및 유지해야 할 CRD가 여러 개(리소스 유형당 하나)
- 코드 중복: 유사한 컨트롤러 로직을 복제하거나 추상화해야 함
- 문서 오버헤드: 각 CRD에 대한 별도 문서 필요
선택된 접근 방식: workloadRef (옵션 2)
이 제안은 다음 이유로 **옵션 2 (workloadRef)**를 기본 접근 방식으로 채택합니다.
- 기존 패턴과의 정렬: 현재 Argo Rollouts가 Deployment에
workloadRef를 사용하는 방식과 동일함 - 플러그인 아키텍처 호환성: 컨트롤러가 리소스에 무관하게 유지되어 플러그인에 위임함
- 최소 CRD 복잡성: CRD를 일반적이고 유지 관리 가능하게 유지함
- canary 배포에 실용적: 플러그인이 참조된 리소스를 조작할 수 있음(예: StatefulSet의 partition 필드)
- blue/green 배포에 실용적: 플러그인이 원본을 blue로 참조하면서 추가 리소스(예: green StatefulSet)를 생성/관리할 수 있음
RolloutPlugin CRD 스펙
workloadRef 접근 방식에서 RolloutPlugin CRD는 다음과 같이 정의됩니다.
apiVersion: argorollouts.io/v1alpha1
kind: RolloutPlugin
metadata:
name: my-statefulset-rollout
spec:
# Reference to the workload being managed
workloadRef:
apiVersion: apps/v1
kind: StatefulSet
name: my-statefulset
namespace: default
# Plugin-specific configuration
plugin:
name: statefulset
verify: true
sha256: "abc123..."
url: "https://example.com/plugins/statefulset"
# Plugin-specific configuration
config:
customField1: "value1"
customField2: "value2"
# Rollout strategy definition
strategy:
# Strategy configuration depends on the type
canary:
steps:
- setWeight: 20
- pause: {duration: 1h}
- setWeight: 40
- pause: {duration: 1h}
- setWeight: 60
- pause: {duration: 1h}
- setWeight: 80
- pause: {duration: 1h}
# BlueGreen configuration would be here
# blueGreen:
# ...
RolloutPlugin 상태 (Status)
RolloutPlugin의 status는 롤아웃의 진행 상황을 추적합니다.
status:
observedGeneration: 1
initialized: true
currentRevision: "hash123456"
updatedRevision: "hash789012"
currentStepIndex: 2
currentStepComplete: false
rolloutInProgress: true
conditions:
- type: Progressing
status: "True"
message: StatefulSet successfully updated to partition 8 (20% weight)
paused: false
aborted: false
# Plugin-specific status fields
pluginStatus:
resourceType: "StatefulSet"
customStatusField1: "value1"
customStatusField2: "value2"
RolloutPlugin Controller 아키텍처
컨트롤러는 서로 다른 리소스 유형에 대한 플러그인을 로드하며, 각 플러그인은 해당 리소스 유형에 필요한 특정 로직을 구현합니다. 컨트롤러 자체는 리소스에 무관하며 리소스별 작업을 플러그인에 위임합니다. RolloutPlugin 컨트롤러는 기존 Argo Rollouts의 플러그인과 유사하게 플러그인 관리를 위해 HashiCorp의 go-plugin 라이브러리를 사용합니다.
일반 플러그인 인터페이스 (Generic Plugin Interface)
// ResourcePhase defines the possible phases of a resource operation
type ResourcePhase string
const (
ResourcePhaseRunning ResourcePhase = "Running"
ResourcePhaseSuccessful ResourcePhase = "Successful"
ResourcePhaseFailed ResourcePhase = "Failed"
ResourcePhaseError ResourcePhase = "Error"
)
// RolloutPluginContext contains information needed by plugin operations
type RolloutPluginContext struct {
// The RolloutPlugin resource
RolloutPlugin *v1alpha1.RolloutPlugin
// Configuration for the plugin operation
Config map[string]interface{}
// Status carries persisted state between operations
Status map[string]interface{}
}
// OperationResult contains the result of an operation
type OperationResult struct {
// Success indicates if the operation was successful
Success bool
// Message provides additional context about the operation
Message string
// Status contains operation-specific status information
Status map[string]interface{}
// Error details if the operation failed
Error *RpcError
// Whether to requeue the reconciliation and after how long
Requeue bool
RequeueAfter time.Duration
}
// RpcError is a structured error for plugin responses
type RpcError struct {
ErrorString string
Code int
Details string
}
// RolloutPlugin defines the generic interface for resource plugins
type RolloutPlugin interface {
// Initialize the plugin with any required setup
Init() error
// CreateResource creates a resource with the specified role
// role can be "stable", "canary", "preview", "active", etc.
CreateResource(ctx RolloutPluginContext, role string) OperationResult
// UpdateResource updates a resource with the specified role
// role can be "stable", "canary", "preview", "active", etc.
UpdateResource(ctx RolloutPluginContext, role string) OperationResult
// ScaleResource scales a resource with the specified role to the desired replica count
ScaleResource(ctx RolloutPluginContext, role string, replicas int32) OperationResult
// SetWeight updates traffic distribution between resources
// For canary: percentage of traffic to canary
// For blue-green: percentage of traffic to preview
SetWeight(ctx RolloutPluginContext, desiredWeight int32) OperationResult
// PromoteResource promotes a resource to become the new stable version
// For canary: promotes canary to stable
// For blue-green: promotes preview to active
PromoteResource(ctx RolloutPluginContext) OperationResult
// Terminate stops an uncompleted operation
Terminate(ctx RolloutPluginContext) OperationResult
// VerifyWeight checks if the desired weight distribution has been achieved
VerifyWeight(ctx RolloutPluginContext, desiredWeight int32) OperationResult
// IsResourceReady checks if a specific resource is considered ready
IsResourceReady(ctx RolloutPluginContext, role string) OperationResult
// GetPluginInfo returns metadata about the plugin
GetPluginInfo() PluginInfo
}
// PluginInfo contains metadata about a plugin
type PluginInfo struct {
Name string
Version string
SupportedResourceKinds []string
SupportedStrategies []string
}
컨트롤러 동기화 흐름 (Controller Reconciliation Flow)
RolloutPlugin 컨트롤러는 다음 동기화 흐름을 따릅니다.
RolloutPlugin리소스 가져오기- 리소스 유형에 따라 적절한 플러그인 초기화
- 현재 상태와 플러그인 동기화
- 현재 인덱스에 따라 단계 처리:
setWeight단계에 대해 플러그인의 SetWeight 메서드 호출pause단계에 대해 컨트롤러에서 pause 로직 처리analysis단계에 대해 analysis run 생성 및 모니터링- 현재 진행 상황으로
RolloutPlugin상태 업데이트 - 다음 동기화를 위해 재큐(requeue)
두 접근 방식에 대한 StatefulSet 구현
어떤 접근 방식을 선택하든, StatefulSet별 구현은 partition 필드를 활용하여 canary 배포를 달성합니다.
StatefulSet용 Canary 배포
canary 배포는 StatefulSet의 partition 기능을 활용합니다.
- partition = replicas로 시작(파드 업데이트 없음)
- 롤아웃이 진행됨에 따라 partition을 점진적으로 감소:
- partition = replicas * (1 - weight/100)
- 10개 replica에 대한 예:
- 20% weight → partition = 8 (2 pods updated)
- 50% weight → partition = 5 (5 pods updated)
- 100% weight → partition = 0 (all pods updated)
- 각 단계에서 파드 상태를 모니터링하고 메트릭 분석
- 실패 시 partition을 replicas로 되돌림(모든 파드 복귀)
- 성공 시 partition을 0으로 설정(모든 파드 업데이트)
StatefulSet은 내림차순(N-1, N-2, ...)으로 업데이트되므로, partition 필드는 업데이트되지 않을 첫 번째 파드를 나타냅니다. 즉 ordinal >= partition인 파드는 이전 버전에 남습니다.
StatefulSet용 Blue/Green 배포
StatefulSet용 blue/green 배포는 상태 저장 특성 때문에 더 복잡합니다. 다음과 같은 접근 방식을 제안합니다.
- 다른 이름(접미사 -green)으로 새 StatefulSet 생성
- 필요하면 새 StatefulSet에 상태(state) 채우기(애플리케이션별 로직 필요할 수 있음)
- service selector 변경을 통해 green StatefulSet으로 새 트래픽 보내기
- green 배포를 검증하기 위해 메트릭 분석
- 성공 시 모든 트래픽을 green 배포로 전환하고 blue 종료
- 실패 시 blue 배포에 트래픽 유지하고 green 정리
이 접근 방식은 애플리케이션별 상태 전송을 요구할 수 있으며, pre/post hooks 또는 커스텀 단계 플러그인을 통해 처리할 수 있습니다.
StatefulSet 사용 사례
사용 사례 1: 상태 저장 데이터베이스의 Canary 배포
현재 과제: 한 팀이 쿠버네티스에서 MongoDB 상태 저장 데이터베이스를 StatefulSet으로 운영합니다. 새 MongoDB 버전으로 업그레이드할 때 현재 두 가지 불만족스러운 옵션이 있습니다.
- 모든 인스턴스를 한 번에 업데이트(위험)
- 시간이 지남에 따라 partition 필드를 수동으로 업데이트(노동 집약적이고 오류 발생 가능)
제안된 해결책: StatefulSet 지원과 함께 두 접근 방식 중 하나를 사용하면 팀은 다음을 할 수 있습니다.
# Approach 1: Using extended Rollout
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: mongodb-rollout
spec:
replicas: 5
workloadRef:
apiVersion: apps/v1
kind: StatefulSet
name: mongodb
resourcePlugin:
name: statefulset
strategy:
canary:
steps:
- setWeight: 20 # Update 1 replica (partition=4)
- pause: {duration: 2h}
- analysis:
templates:
- templateName: mongodb-metrics
- setWeight: 40 # Update 2 replicas (partition=3)
- pause: {duration: 2h}
- setWeight: 100 # Update all replicas (partition=0)
# Approach 2: Using RolloutPlugin CRD
apiVersion: argorollouts.io/v1alpha1
kind: RolloutPlugin
metadata:
name: mongodb-rollout
spec:
workloadRef:
apiVersion: apps/v1
kind: StatefulSet
name: mongodb
plugin:
name: statefulset
verify: true
sha256: "abc123..."
url: "https://example.com/plugins/statefulset"
strategy:
type: Canary
canary:
steps:
- setWeight: 20 # Update 1 replica (partition=4)
- pause: {duration: 2h}
- analysis:
templates:
- templateName: mongodb-metrics
- setWeight: 40 # Update 2 replicas (partition=3)
- pause: {duration: 2h}
- setWeight: 100 # Update all replicas (partition=0)
사용 사례 2: 상태 저장 메시지 큐의 Blue/Green 배포
현재 과제: 한 팀이 Kafka 클러스터를 StatefulSet으로 운영합니다. 새 버전을 프로덕션 트래픽으로 테스트하면서 문제가 감지되면 즉시 롤백할 수 있어야 합니다.
제안된 해결책: StatefulSet blue/green 지원과 함께 두 접근 방식 중 하나를 사용합니다.
# Approach 1: Using extended Rollout
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: kafka-rollout
spec:
replicas: 3
workloadRef:
apiVersion: apps/v1
kind: StatefulSet
name: kafka
resourcePlugin:
name: statefulset
strategy:
blueGreen:
activeService: kafka-active
previewService: kafka-preview
autoPromotionEnabled: false
previewReplicaCount: 3
scaleDownDelaySeconds: 600
analysis:
templates:
- templateName: kafka-metrics
# Approach 2: Using RolloutPlugin CRD
apiVersion: argorollouts.io/v1alpha1
kind: RolloutPlugin
metadata:
name: kafka-rollout
spec:
workloadRef:
apiVersion: apps/v1
kind: StatefulSet
name: kafka
plugin:
name: statefulset
verify: true
sha256: "abc123..."
url: "https://example.com/plugins/statefulset"
strategy:
blueGreen:
activeService: kafka-active
previewService: kafka-preview
autoPromotionEnabled: false
previewReplicaCount: 3
scaleDownDelaySeconds: 600
analysis:
templates:
- templateName: kafka-metrics
ReplicaSet 사용 사례
RolloutPlugin 접근 방식의 유연성을 보여주기 위해 ReplicaSet에 대한 더 간단한 사용 사례가 있습니다.
사용 사례 1: ReplicaSet을 사용한 단순 Canary 배포
현재 과제: 한 팀이 전체 Deployment를 사용하지 않고 서비스에 변경 사항을 점진적으로 출시하는 가벼운 방법을 원하며, 제어된 증분과 단계 사이의 자동 분석을 원합니다.
제안된 해결책:
apiVersion: argorollouts.io/v1alpha1
kind: RolloutPlugin
metadata:
name: simple-canary-rs
spec:
workloadRef:
apiVersion: apps/v1
kind: Deployment
name: canary-app
plugin:
name: Deployment
verify: true
sha256: "abc123..."
url: "https://example.com/plugins/replicaset"
config:
revisionHistoryLimit: 3
strategy:
type: Canary
canary:
steps:
- setWeight: 20
- pause: {duration: 10m}
- analysis:
templates:
- templateName: success-rate
- setWeight: 40
- pause: {duration: 10m}
- setWeight: 60
- analysis:
templates:
- templateName: success-rate
- setWeight: 100
사용 사례 2: ReplicaSet을 사용한 단순 Blue/Green 배포
현재 과제: 한 팀이 preview 환경과 함께 무중단 업데이트가 필요한 서비스에 대해 blue/green 배포를 구현하는 간단한 방법을 원합니다.
제안된 해결책:
apiVersion: argorollouts.io/v1alpha1
kind: RolloutPlugin
metadata:
name: bluegreen-rs
spec:
workloadRef:
apiVersion: apps/v1
kind: Deployment
name: bluegreen-app
plugin:
name: Deployment
verify: true
sha256: "abc123..."
url: "https://example.com/plugins/replicaset"
strategy:
type: BlueGreen
blueGreen:
activeService: bluegreen-active
previewService: bluegreen-preview
autoPromotionEnabled: false
prePromotionAnalysis:
templates:
- templateName: http-success-rate
scaleDownDelaySeconds: 300
이 사용 사례들은 RolloutPlugin 접근 방식이 ReplicaSet을 직접 관리하여 제어된 롤아웃 전략을 구현할 수 있음을 보여줍니다. 플러그인 아키텍처는 핵심 롤아웃 기능을 유지하면서 ReplicaSet 수명 주기에 대한 정밀한 제어를 가능하게 합니다.
RolloutPlugin Controller 접근 방식의 장점
- 기존 컨트롤러와의 깔끔한 분리: 기존 Rollout 기능에 영향을 줄 위험이 없음
- 리소스별 최적화: 서로 다른 리소스 유형에 맞게 특별히 최적화 가능
- 리소스별 기능 구현 용이: 전용 컨트롤러가 핵심 Rollouts 컨트롤러를 복잡하게 하지 않고 리소스별 기능을 허용
- 독립적 진화: 기존 Rollouts 컨트롤러와 독립적으로 진화 가능
- 명확한 플러그인 경계: 플러그인 개발자를 위한 잘 정의된 인터페이스
보안 고려 사항 (Security Considerations)
- 리소스 플러그인은 컨트롤러와 동일한 권한으로 실행됨
- RBAC로 플러그인 범위를 제한하는 것을 고려
- 체크섬으로 플러그인 바이너리 검증
위험 및 완화 (Risks and Mitigations)
- 위험: StatefulSet 업데이트 중 데이터 손실 완화: PVC 처리에 대한 명확한 문서와 지침
- 위험: 업데이트 중 서비스 중단 완화: 보수적인 기본 설정과 철저한 분석 템플릿
- 위험: 플러그인 안정성이 컨트롤러에 영향 완화: 플러그인 실행에서 적절한 오류 처리와 격리
결론 (Conclusion)
이 제안은 Argo Rollouts가 여러 리소스 유형을 지원하도록 확장하는 플러그인 아키텍처를 정의하며, 초기 초점은 StatefulSets입니다. 이 접근 방식은 다양한 쿠버네티스 리소스에 대한 고급 배포 전략을 관리하는 방법을 제공하여 사용자가 전체 인프라에 걸쳐 일관된 롤아웃 패턴을 적용할 수 있게 합니다.
StatefulSet 구현은 기존 쿠버네티스 기능(partition 필드)을 활용해 고급 배포 전략을 제공하는 방법을 보여주며, 이 아키텍처는 향후 리소스 유형이 기존 코드에 대한 최소한의 변경으로 지원될 수 있도록 보장합니다.
참고 자료 (References)
- Kubernetes StatefulSet documentation: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
- Kubernetes StatefulSet update strategies: https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#updating-statefulsets
- Argo Rollouts plugin architecture: https://argoproj.github.io/argo-rollouts/plugins/
- HashiCorp go-plugin library: https://github.com/hashicorp/go-plugin
아카이브: 고려된 대체 접근 방식
접근 방식 1: 리소스 플러그인 확장 (선택되지 않음)
이 접근 방식은 고려되었지만 선택되지 않았습니다. 기존 Rollouts 컨트롤러를 리소스 플러그인 시스템으로 확장하여 현재 Rollout CRD가 다른 리소스 유형을 관리할 수 있게 하는 방식이었습니다.
선택되지 않은 이유:
- 기존 기능에 영향을 줄 위험이 더 높음
- 잠재적으로 더 복잡한 컨트롤러 코드
- 기존 Rollouts 구현과의 더 긴밀한 결합
장점:
- 기존 Rollouts와의 통합된 사용자 경험
- 유지 관리할 컨트롤러가 하나
- 기존 CLI 명령과 UI 재사용
일반 리소스 플러그인 인터페이스
이 접근 방식의 핵심은 모든 쿠버네티스 리소스 유형에서 작동하고 canary 및 blue-green 배포 전략을 모두 지원할 만큼 일반적인 메서드를 가진 플러그인 인터페이스였습니다.
// ResourcePhase defines the possible phases of a resource operation
type ResourcePhase string
const (
ResourcePhaseRunning ResourcePhase = "Running"
ResourcePhaseSuccessful ResourcePhase = "Successful"
ResourcePhaseFailed ResourcePhase = "Failed"
ResourcePhaseError ResourcePhase = "Error"
)
// ResourceContext contains information and configuration for resource plugin operations
type ResourceContext struct {
// Plugin name
PluginName string
// Configuration for the plugin operation
Config map[string]interface{}
// Status carries persisted state between operations
Status map[string]interface{}
}
// ResourceStatus represents the status of a resource plugin operation
type ResourceStatus struct {
// Resource identifier (e.g. hash of the spec)
ResourceId string
// The current phase of the operation
Phase ResourcePhase
// Human-readable message about the operation
Message string
// Start time of the operation
StartedAt *metav1.Time
// Finish time of the operation
FinishedAt *metav1.Time
// Resource-specific status information (persisted between operations)
Status map[string]interface{}
// Wait time before checking status again for incomplete operations
RequeueAfter time.Duration
}
// ResourceResult contains the result of a plugin operation
type ResourceResult struct {
// The resulting phase of the operation
Phase ResourcePhase
// Human-readable message about the operation result
Message string
// Resource-specific status information to persist
Status map[string]interface{}
// Wait time before executing the operation again for incomplete operations
RequeueAfter time.Duration
}
type ResourcePlugin interface {
// Initialize the plugin
Init() error
// CreateResource creates or ensures a resource with the given role exists
// role can be "stable", "canary", "preview", "active", etc.
CreateResource( rollout *v1alpha1.Rollout, resourceContext *ResourceContext, role string) (*ResourceResult, error)
// UpdateResource updates a resource with the given role
// role can be "stable", "canary", "preview", "active", etc.
UpdateResource( rollout *v1alpha1.Rollout, resourceContext *ResourceContext, role string) (*ResourceResult, error)
// ScaleResource scales a resource with the given role to the desired replica count
ScaleResource( rollout *v1alpha1.Rollout, resourceContext *ResourceContext, role string, replicas int32) (*ResourceResult, error)
// SetWeight updates the traffic weight between resources
// For canary: percentage of traffic to canary
// For blue-green: percentage of traffic to preview
SetWeight( rollout *v1alpha1.Rollout, resourceContext *ResourceContext, desiredWeight int32) (*ResourceResult, error)
// SwitchTrafficRoute changes the routing of traffic between resources
// Particularly useful for blue-green to route traffic to preview
SwitchTrafficRoute( rollout *v1alpha1.Rollout, resourceContext *ResourceContext, options map[string]string) (*ResourceResult, error)
// PromoteResource promotes a resource to become the new stable/active version
// For canary: promotes canary to stable
// For blue-green: promotes preview to active
PromoteResource( rollout *v1alpha1.Rollout, resourceContext *ResourceContext) (*ResourceResult, error)
// Terminate stops an uncompleted operation
Terminate( rollout *v1alpha1.Rollout, resourceContext *ResourceContext) (*ResourceResult, error)
// VerifyWeight verifies if the desired weight distribution has been achieved
VerifyWeight( rollout *v1alpha1.Rollout, resourceContext *ResourceContext, desiredWeight int32) (bool, error)
// IsResourceReady returns whether a specific resource is considered ready
IsResourceReady( rollout *v1alpha1.Rollout, resourceContext *ResourceContext, role string) (bool, error)
// Type returns the type/name of the resource plugin
Type() string
// SupportsStrategy returns whether the plugin supports a given deployment strategy
SupportsStrategy(strategy StrategyType) bool
}
확장된 Rollout 스펙
Rollout 스펙은 resourcePlugin 필드로 확장됩니다.
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: statefulset-rollout
spec:
replicas: 5
workloadRef:
apiVersion: apps/v1
kind: StatefulSet
name: my-statefulset
resourcePlugin:
name: statefulset
config:
# Optional plugin-specific configuration
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
strategy:
# Existing strategy remains unchanged
canary:
steps:
- setWeight: 20
- pause: {duration: 1h}
- setWeight: 40
- pause: {duration: 1h}
Rollout 상태 확장
Rollout status는 resourcePluginStatus 필드로 확장됩니다.
status:
canary:
resourcePluginStatus:
- name: statefulset
message: "Updated partition to 3 (60%)"
phase: Running
startedAt: "2025-08-03T12:00:00Z"
status:
partition: 3
currentReplicas: 3
updatedReplicas: 2
접근 방식 1의 예시 사용 사례
확장된 Rollout을 사용한 StatefulSet Canary
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: mongodb-rollout
spec:
replicas: 5
workloadRef:
apiVersion: apps/v1
kind: StatefulSet
name: mongodb
resourcePlugin:
name: statefulset
strategy:
canary:
steps:
- setWeight: 20 # Update 1 replica (partition=4)
- pause: {duration: 2h}
- analysis:
templates:
- templateName: mongodb-metrics
- setWeight: 40 # Update 2 replicas (partition=3)
- pause: {duration: 2h}
- setWeight: 100 # Update all replicas (partition=0)
확장된 Rollout을 사용한 StatefulSet Blue/Green
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: kafka-rollout
spec:
replicas: 3
workloadRef:
apiVersion: apps/v1
kind: StatefulSet
name: kafka
resourcePlugin:
name: statefulset
strategy:
blueGreen:
activeService: kafka-active
previewService: kafka-preview
autoPromotionEnabled: false
previewReplicaCount: 3
scaleDownDelaySeconds: 600
analysis:
templates:
- templateName: kafka-metrics
확장된 Rollout을 사용한 ReplicaSet Canary
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: simple-replicaset-canary
spec:
replicas: 10
resourcePlugin:
name: replicaset
config:
revisionHistoryLimit: 3
selector:
matchLabels:
app: canary-app
template:
metadata:
labels:
app: canary-app
spec:
containers:
- name: app
image: myapp:v2
ports:
- containerPort: 8080
strategy:
canary:
steps:
- setWeight: 20 # Create canary ReplicaSet with 2 replicas (20% of 10)
- pause: {duration: 10m}
- analysis:
templates:
- templateName: success-rate
- setWeight: 40 # Scale canary ReplicaSet to 4 replicas (40% of 10)
- pause: {duration: 10m}
- setWeight: 60 # Scale canary ReplicaSet to 6 replicas (60% of 10)
- analysis:
templates:
- templateName: success-rate
- setWeight: 100 # Scale canary ReplicaSet to 10 replicas, scale down stable
확장된 Rollout을 사용한 ReplicaSet Blue/Green
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: bluegreen-replicaset
spec:
replicas: 5
resourcePlugin:
name: replicaset
selector:
matchLabels:
app: bluegreen-app
template:
metadata:
labels:
app: bluegreen-app
spec:
containers:
- name: app
image: myapp:v2
ports:
- containerPort: 8080
strategy:
blueGreen:
activeService: bluegreen-active
previewService: bluegreen-preview
autoPromotionEnabled: false
prePromotionAnalysis:
templates:
- templateName: http-success-rate
scaleDownDelaySeconds: 300
더 알아보기 (Learn more)
- Argo Rollouts 플러그인 아키텍처와 go-plugin 사용법 익히기
- Canary 및 Blue/Green 배포 전략의 기본 개념 이해하기
- AnalysisTemplate을 활용한 자동화된 배포 검증 알아보기
- StatefulSet의 partition 필드와 업데이트 전략 이해하기