Rollouts용 리소스 플러그인 (Resource Plugin for Rollouts)
이 문서는 Argo Rollouts를 확장해 Deployment 외의 다양한 Kubernetes 리소스 유형(초기에는 StatefulSets에 초점)에 대해 고급 배포 전략(canary와 blue/green)을 지원하는 플러그인 기반 아키텍처를 제안해요.
출처: 문서
본문
이 문서는 Argo Rollouts를 확장해 Deployment 외의 다양한 Kubernetes 리소스 유형(초기에는 StatefulSets에 초점)에 대해 고급 배포 전략(canary와 blue/green)을 지원하는 플러그인 기반 아키텍처를 제안해요.
Summary
현재 Argo Rollouts는 내부적으로 ReplicaSets를 관리하는 Deployment 워크로드 유형만 지원해요. 이 제안은 새로운 전용 RolloutPlugin Controller가 새 CRD를 관리하는 플러그인 아키텍처를 통해 Argo Rollouts가 다른 Kubernetes 리소스도 지원하도록 확장하는 것을 목표로 해요.
이 접근 방식은 기존 컨트롤러와의 깔끔한 분리를 만들고, 커뮤니티가 추가 리소스 유형을 위해 확장할 수 있는 프레임워크를 제공하면서 리소스별 최적화를 가능하게 해요.
Motivation
현재 Rollouts 컨트롤러는 ReplicaSets에 밀접하게 결합되어 있어 Deployment 워크로드만 지원하도록 제한돼요. 많은 사용자가 StatefulSets, DaemonSets, 그리고 잠재적으로 사용자 지정 리소스와 같은 다른 워크로드 유형에 대해 canary나 blue-green 업그레이드를 수행해야 해요. 플러그인 아키텍처를 구현하면 새 리소스마다 컨트롤러를 크게 다시 작성하지 않고도 이러한 리소스 유형을 지원할 수 있어요.
StatefulSets는 상태 저장 애플리케이션 배포에서 널리 사용되므로 설득력 있는 초기 사용 사례를 제공해요. StatefulSets의 네이티브 업데이트 기능은 선택적 partition 기반 업데이트를 가진 기본 롤링 업데이트로 제한되며, 다음을 지원하지 않아요:
-
업데이트 중 제어된 트래픽 분산
-
업데이트의 자동 분석 및 검증
-
점진적 트래픽 이동
-
자동 canary 분석
-
즉시 롤백이 가능한 blue/green 배포
Goals
-
어떤 Kubernetes 리소스 유형과도 함께 동작할 수 있는 플러그인 아키텍처를 정의하기
-
핵심 rollout 기능을 유지하면서 리소스별 세부 사항을 추상화하는 인터페이스를 만들기
-
초기 구현으로 StatefulSets에 대한 canary와 blue/green 배포를 지원하기
-
기존 Argo Rollouts 기능과의 호환성 유지하기
-
커뮤니티가 추가 리소스 유형으로 확장할 수 있는 프레임워크 제공하기
Non-Goals
-
어떤 리소스 유형에 대해서도 핵심 Kubernetes 컨트롤러를 수정하기
-
이 제안 안에서 모든 가능한 리소스 유형을 구현하기
-
네이티브로 지원하지 않는 리소스에 대한 in-place 업데이트 지원하기
-
모든 사용 사례를 내부에서 처리하려는 모놀리식 솔루션 만들기
Proposed Implementation: RolloutPlugin Controller
이 접근 방식에는 RolloutPlugin이라는 새 Custom Resource Definition(CRD)을 관리하는 전용 컨트롤러를 만드는 것이 포함돼요. 이 컨트롤러는 기존 Argo Rollouts 컨트롤러와 완전히 분리되어 깔끔한 분리와 리소스별 최적화를 제공해요. 새 컨트롤러의 구현은 네이티브 informers 대신 controller-runtime 라이브러리를 사용해 진행돼요. 이 라이브러리가 그렇지 않으면 필요했을 많은 보일러플레이트 코드를 추상화해 주기 때문이에요.
Traffic Routing and Scaling Strategy
RolloutPlugin CRD와 컨트롤러는 트래픽 관리보다는 네이티브 리소스 기능(예: StatefulSet partition 필드)을 통한 progressive delivery에 초점을 맞춰요.
주요 결정:
setCanaryScale 필드 없음: Pod 수를 트래픽 라우팅과 결합하지 않기 위해, CRD는 기존 Rollout CRD에서 사용되는 setCanaryScale 필드를 구현하지 않아요. 이는 replica/pod 수의 개념을 트래픽 분산에서 분리해요.
가중치 전용 접근: CRD는 rollout 진행을 제어하기 위해 setWeight steps만 사용해요. StatefulSets의 경우 이는 트래픽 비율이 아니라 partition 필드 조작(업데이트되는 pod의 백분율)으로 변환돼요.
미래 플러그인 확장성: 트래픽 라우팅은 초기 범위에 없지만, CRD와 플러그인 인터페이스는 특정 리소스 유형에 필요할 경우 개별 플러그인이 향후 트래픽 라우팅 기능을 구현할 수 있도록 설계돼요. 이는 핵심 컨트롤러를 단순하게 유지하면서 향후 개선을 위한 유연성을 유지해요.
예시: 10개의 replica가 있는 StatefulSet에서 setWeight: 40은 partition: 6을 설정해 4개 pod(전체 replica의 40%)를 업데이트한다는 뜻이에요. 트래픽의 40%가 그 pod로 간다는 뜻이 아니라요.
RolloutPlugin CRD
RolloutPlugin CRD는 모든 Kubernetes 리소스 유형의 rollout을 관리하기 위한 일반적인 인터페이스를 정의해요.
CRD Design Options for Resource Specification
RolloutPlugin CRD가 여러 Kubernetes 리소스 유형(StatefulSets, DaemonSets 등)을 지원할 만큼 일반적이어야 하므로, 사용자가 관리할 리소스를 지정하는 방법에는 세 가지 잠재적 접근 방식이 있어요:
Option 1: Embed Resource Specs in the CRD
이 접근 방식은 각 가능한 리소스 유형의 완전한 스펙을 RolloutPlugin CRD에 직접 포함해요.
예시:
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:
# ...
장점:
- 자족적(self-contained): 모든 구성이 한 곳에 있어 외부 의존성이 없음
- 버전 관리 친화적: 원하는 전체 구성을 하나의 리소스에 포착
- 초기 배포: 워크로드와 rollout 관리를 함께 생성 가능
단점:
- CRD 복잡성: 여러 리소스 유형 스펙이 있는 매우 큰 CRD 스키마
- 유지 관리 부담: CRD를 업스트림 Kubernetes 리소스 정의와 동기화해야 함
- 마이그레이션 어려움: 기존 워크로드를 다시 만들거나 스펙을 복사해야 함
Option 2: Reference Existing Kubernetes Objects (권장)
이 접근 방식은 workloadRef를 사용해 이미 생성된 Kubernetes 리소스를 이름과 네임스페이스로 참조해요.
예시:
apiVersion: argorollouts.io/v1alpha1
kind: RolloutPlugin
metadata:
name: my-rollout
spec:
workloadRef:
apiVersion: apps/v1
kind: StatefulSet
name: my-statefulset
namespace: default
strategy:
# ...
장점:
- 단순한 CRD: 참조 필드만 있으면 되는 최소한의 CRD 스키마
- 관심사 분리: 워크로드 정의가 rollout 전략과 분리
- 기존 리소스와 동작: 워크로드를 다시 만들지 않고 기존 워크로드에 rollout 기능을 추가 가능
- 표준 Kubernetes 패턴: HPA가 Deployment를 참조하고 Rollout이 Deployment를 참조하는 기존 패턴을 따름
- 더 쉬운 유지 관리: CRD를 Kubernetes 리소스 스키마와 동기화할 필요 없음
- 명확한 소유권: 원래 리소스가 워크로드 스펙의 진실의 원천(source of truth)으로 남음
단점:
- 2단계 프로세스: 먼저 워크로드를 만든 다음 RolloutPlugin을 만들어야 함
- 조정 복잡성: 워크로드 스펙 업데이트가 rollout 전략과 조정이 필요함
Option 3: Create Dedicated CRDs per Resource Type
이 접근 방식은 각 리소스 유형에 대해 StatefulSetRollout, DaemonSetRollout 등과 같은 별도의 CRD를 만드는 것이에요.
예시:
apiVersion: argorollouts.io/v1alpha1
kind: StatefulSetRollout
metadata:
name: my-sts-rollout
spec:
statefulSetSpec:
# StatefulSet specific fields
strategy:
# Rollout strategy
장점:
- 타입 안전성: 각 CRD가 특정 리소스에 대해 강력하게 타입이 지정됨
- 독립적 진화: 각 CRD가 독립적으로 진화 가능
- 리소스별 기능: 리소스별 rollout 기능을 쉽게 추가 가능
단점:
- 유지 관리 부담: 설치하고 유지할 CRD가 여러 개(리소스 유형당 하나)
- 코드 중복: 유사한 컨트롤러 로직을 복제하거나 추상화해야 함
- 문서 오버헤드: 각 CRD에 대한 별도 문서 필요
Selected Approach: workloadRef (Option 2)
이 제안은 다음 이유로 Option 2(workloadRef)를 기본 접근 방식으로 채택해요:
-
기존 패턴과의 정렬: 현재 Argo Rollouts가 Deployment에
workloadRef를 사용하는 방식을 반영 -
플러그인 아키텍처 호환성: 컨트롤러가 리소스에 구애받지 않고 플러그인에 위임
-
최소 CRD 복잡성: CRD를 일반적이고 유지 관리 가능하게 유지
-
canary 배포에 실용적: 플러그인이 참조된 리소스를 조작 가능(예: StatefulSets의 partition 필드)
-
blue/green 배포에 실용적: 플러그인이 원본을 blue로 참조하면서 추가 리소스(예: green StatefulSet)를 생성/관리 가능
RolloutPlugin CRD Specification
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는 rollout의 진행 상황을 추적해요:
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 Architecture
컨트롤러는 서로 다른 리소스 유형의 플러그인을 로드하며, 각 플러그인은 해당 리소스 유형에 필요한 특정 로직을 구현해요. 컨트롤러 자체는 리소스에 구애받지 않으며, 리소스별 작업을 플러그인에 위임해요. 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리소스를 가져와요 -
리소스 유형에 따라 적절한 플러그인을 초기화해요
-
플러그인을 현재 상태와 동기화해요
-
현재 인덱스를 기준으로 steps를 처리해요:
-
setWeightsteps의 경우 플러그인의 SetWeight 메서드를 호출해요 -
pausesteps의 경우 컨트롤러에서 일시 중지 로직을 처리해요 -
analysissteps의 경우 analysis runs를 만들고 모니터링해요 -
현재 진행 상황으로
RolloutPluginstatus를 업데이트해요 -
다음 조정을 위해 재큐(re-queue)해요
StatefulSet Implementation for Both Approaches
어떤 접근 방식을 선택하든, StatefulSet별 구현은 canary 배포를 달성하기 위해 partition 필드를 활용할 거예요:
Canary Deployment for StatefulSets
canary 배포는 StatefulSet의 partition 기능을 활용해요:
-
partition = replicas로 시작 (업데이트된 pod 없음)
-
rollout이 진행됨에 따라 partition을 점차 감소시켜요:
-
partition = replicas * (1 - weight/100)
-
10개 replica를 위한 예시:
-
20% weight → partition = 8 (2개 pod 업데이트)
-
50% weight → partition = 5 (5개 pod 업데이트)
-
100% weight → partition = 0 (모든 pod 업데이트)
-
각 단계에서 pod 상태를 모니터링하고 메트릭을 분석해요
-
실패 시 partition을 replicas로 되돌려요 (모든 pod 되돌리기)
-
성공 시 partition을 0으로 설정해요 (모든 pod 업데이트)
StatefulSets는 내림차순(N-1, N-2, ...)으로 업데이트되므로, partition 필드는 업데이트되지 않을 첫 번째 pod를 나타내요. 즉 ordinal >= partition인 pod는 이전 버전에 남아요.
Blue/Green Deployment for StatefulSets
StatefulSets의 blue/green 배포는 상태 저장 특성으로 인해 더 복잡해요. 다음 접근 방식을 제안해요:
-
새 이름으로 새 StatefulSet을 만들어요 (접미사 -green)
-
필요한 경우 새 StatefulSet에 상태를 채워요 (애플리케이션별 로직이 필요할 수 있음)
-
서비스 셀렉터 변경을 통해 새 트래픽을 green StatefulSet으로 보내요
-
green 배포를 검증하기 위해 메트릭을 분석해요
-
성공 시 모든 트래픽을 green 배포로 전환하고 blue를 폐기해요
-
실패 시 트래픽을 blue 배포에 유지하고 green을 정리해요
이 접근 방식은 애플리케이션별 상태 전송이 필요할 수 있으며, pre/post 훅이나 사용자 지정 step 플러그인으로 처리할 수 있어요.
StatefulSet Use Cases
Use Case 1: Canary Deployment of Stateful Database
현재 과제: 팀이 Kubernetes의 StatefulSet으로 상태 저장 MongoDB 데이터베이스를 운영해요. 새 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)
Use Case 2: Blue/Green Deployment of Stateful Message Queue
현재 과제: 팀이 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 Use Cases
RolloutPlugin 접근 방식의 유연성을 보여주기 위해 ReplicaSets에 대한 더 간단한 사용 사례가 있어요.
Use Case 1: Simple Canary Deployment with ReplicaSets
현재 과제: 팀이 전체 Deployments를 사용하지 않고도 제어된 증분과 단계별 자동 분석으로 서비스에 변경 사항을 점진적으로 롤아웃할 수 있는 가벼운 방법을 원해요.
제안된 해결책:
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
Use Case 2: Simple Blue/Green Deployment with ReplicaSets
현재 과제: 팀이 프리뷰 환경으로 무중단 업데이트가 필요한 서비스에 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 접근 방식이 제어된 rollout 전략을 구현하기 위해 ReplicaSets를 직접 관리할 수 있다는 것을 보여줘요. 플러그인 아키텍처는 핵심 rollout 기능을 유지하면서 ReplicaSet 라이프사이클에 대한 정밀한 제어를 가능하게 해요.
Advantages of the RolloutPlugin Controller Approach
-
기존 컨트롤러와의 깔끔한 분리: 기존 Rollout 기능에 영향을 줄 위험이 없음
-
리소스별 최적화: 서로 다른 리소스 유형에 맞게 특별히 최적화 가능
-
리소스별 기능 구현 용이: 전용 컨트롤러가 핵심 Rollouts 컨트롤러를 복잡하게 하지 않고 리소스별 기능을 허용
-
독립적 진화: 기존 Rollouts 컨트롤러와 독립적으로 진화 가능
-
명확한 플러그인 경계: 플러그인 개발자를 위한 잘 정의된 인터페이스
Security Considerations
-
리소스 플러그인은 컨트롤러와 동일한 권한으로 실행돼요
-
RBAC로 플러그인 범위를 제한하는 것을 고려해요
-
체크섬으로 플러그인 바이너리를 검증해요
Risks and Mitigations
위험: StatefulSet 업데이트 중 데이터 손실 완화: PVC 처리에 대한 명확한 문서와 안내 제공
위험: 업데이트 중 서비스 중단 완화: 보수적인 기본 설정과 철저한 분석 템플릿
위험: 플러그인 안정성이 컨트롤러에 영향 완화: 플러그인 실행에서 적절한 오류 처리와 격리
Conclusion
이 제안은 Argo Rollouts를 초기에는 StatefulSets에 초점을 맞춰 여러 리소스 유형을 지원하도록 확장하는 플러그인 아키텍처를 정의해요. 이 접근 방식은 다양한 Kubernetes 리소스에 대해 고급 배포 전략을 관리하는 방법을 제공하며, 사용자가 전체 인프라에 걸쳐 일관된 rollout 패턴을 적용할 수 있게 해줘요.
StatefulSet 구현은 기존 Kubernetes 기능(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
Archive: Alternative Approach Considered
Approach 1: Resource Plugin Extension (선택되지 않음)
이 접근 방식은 고려되었으나 선택되지 않았어요. 기존 Rollouts 컨트롤러를 리소스 플러그인 시스템으로 확장하여 현재 Rollout CRD가 다른 리소스 유형을 관리할 수 있게 했을 거예요.
선택하지 않은 이유:
-
기존 기능에 영향을 줄 위험이 더 높음
-
잠재적으로 더 복잡한 컨트롤러 코드
-
기존 Rollouts 구현과의 더 긴밀한 결합
장점:
-
기존 Rollouts와의 통합된 사용자 경험
-
유지할 컨트롤러가 하나
-
기존 CLI 명령과 UI 재사용
Generic Resource Plugin Interface
이 접근 방식의 핵심은 어떤 Kubernetes 리소스 유형과도 함께 동작하고 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
}
Extended Rollout Spec
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 Status Extensions
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
Example Use Cases for Approach 1
StatefulSet Canary with 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)
StatefulSet Blue/Green with 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
ReplicaSet Canary with Extended Rollout
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
ReplicaSet Blue/Green with Extended Rollout
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