feat: convert Deployment to Rollout CRD with canary strategy

- Replace deployment.yaml with rollout.yaml
- Add canary-service.yaml for traffic splitting
- Add analysistemplate.yaml for Prometheus health checks
- Update HTTPRoute with dual backends (stable + canary)
- Update overlays with Rollout patches
- Add Rollout transformer configuration for Kustomize
This commit is contained in:
Admin
2026-02-01 23:24:13 +00:00
parent fc5c6de051
commit eaf56bc1b6
10 changed files with 108 additions and 28 deletions

View File

@@ -0,0 +1,22 @@
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
labels:
app: myapp
managed-by: argocd
spec:
args:
- name: service-name
metrics:
- name: success-rate
interval: 30s
successCondition: result[0] >= 0.95
failureLimit: 3
provider:
prometheus:
address: http://kube-prometheus-stack-prometheus.monitoring.svc.cluster.local:9090
query: |
sum(rate(http_requests_total{service="{{args.service-name}}",code=~"2.."}[1m]))
/
sum(rate(http_requests_total{service="{{args.service-name}}"}[1m]))

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: myapp-canary
labels:
app: myapp
managed-by: argocd
spec:
selector:
app: myapp
ports:
- port: 80
targetPort: 80

View File

@@ -1,21 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
labels:
app: myapp
managed-by: argocd
spec:
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: nginx:alpine
ports:
- containerPort: 80

View File

@@ -17,3 +17,5 @@ spec:
backendRefs: backendRefs:
- name: myapp - name: myapp
port: 80 port: 80
- name: myapp-canary
port: 80

View File

@@ -2,6 +2,11 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- deployment.yaml - rollout.yaml
- service.yaml - service.yaml
- canary-service.yaml
- httproute.yaml - httproute.yaml
- analysistemplate.yaml
configurations:
- https://argoproj.github.io/argo-rollouts/features/kustomize/rollout-transform-kustomize-v5.yaml

View File

@@ -0,0 +1,47 @@
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: myapp
labels:
app: myapp
managed-by: argocd
spec:
revisionHistoryLimit: 3
selector:
matchLabels:
app: myapp
strategy:
canary:
canaryService: myapp-canary
stableService: myapp
trafficRouting:
plugins:
argoproj-labs/gatewayAPI:
httpRoute: myapp-route
namespace: default
analysis:
templates:
- templateName: success-rate
args:
- name: service-name
value: myapp
startingStep: 1
steps:
- setWeight: 10
- pause: {duration: 30s}
- setWeight: 30
- pause: {duration: 1m}
- setWeight: 60
- pause: {duration: 1m}
- setWeight: 100
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: nginx:alpine
ports:
- name: http
containerPort: 80

View File

@@ -7,7 +7,7 @@ resources:
- ../../base - ../../base
patches: patches:
- path: deployment-patch.yaml - path: rollout-patch.yaml
- path: httproute-patch.yaml - path: httproute-patch.yaml
images: images:

View File

@@ -1,9 +1,15 @@
apiVersion: apps/v1 apiVersion: argoproj.io/v1alpha1
kind: Deployment kind: Rollout
metadata: metadata:
name: myapp name: myapp
spec: spec:
replicas: 2 replicas: 2
strategy:
canary:
trafficRouting:
plugins:
argoproj-labs/gatewayAPI:
namespace: myapp-production
template: template:
spec: spec:
containers: containers:

View File

@@ -7,7 +7,7 @@ resources:
- ../../base - ../../base
patches: patches:
- path: deployment-patch.yaml - path: rollout-patch.yaml
- path: httproute-patch.yaml - path: httproute-patch.yaml
images: images:

View File

@@ -1,9 +1,15 @@
apiVersion: apps/v1 apiVersion: argoproj.io/v1alpha1
kind: Deployment kind: Rollout
metadata: metadata:
name: myapp name: myapp
spec: spec:
replicas: 1 replicas: 1
strategy:
canary:
trafficRouting:
plugins:
argoproj-labs/gatewayAPI:
namespace: myapp-staging
template: template:
spec: spec:
containers: containers: