forked from Stellar-IndigoPay/Stellar-IndigoPay
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargo-rollouts-canary.yaml
More file actions
147 lines (146 loc) · 4.61 KB
/
Copy pathargo-rollouts-canary.yaml
File metadata and controls
147 lines (146 loc) · 4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# gitops/argo-rollouts-canary.yaml
#
# Argo Rollouts STEPPED canary strategy for the backend. Replaces the
# `Deployment` in k8s/backend.yaml with a `Rollout` that performs a
# stepped rollout via pod replacement (20% → 50% → 100% of new-revision
# pods, with 5-min analysis pauses between steps).
#
# IMPORTANT — this is Argo Rollouts' DEFAULT mode. Both `canaryService`
# and `stableService` point at the same `backend-svc`, so the Rollout
# does NOT split live HTTP traffic between two Service revisions. It
# replaces pods in-place at each `setWeight` step. For real traffic-
# split canary (e.g. 5% of user traffic to the new revision), add a
# `trafficRouting` block — Istio, NGINX, ALB, or Ambassador. The
# bottom of this file has an Istio example commented out.
#
# Each new release:
# 1. Deploys 20% of pods with the new revision.
# 2. Watches the canary metrics for 5 minutes; aborts on regression.
# 3. Graduates to 50%, then 100%, with a 5-minute pause between
# steps.
# 4. On full rollout, scales down the old revision.
#
# Prerequisite: install argo-rollouts in the cluster.
# kubectl create namespace argo-rollouts
# kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml
#
# Migration: when you adopt this, delete the existing Deployment
# `backend` (the Rollout takes over the same selector). The Service
# continues to select `app: backend`; no service change is required.
#
# Switch the Deployment→Rollout via:
# kubectl apply -f gitops/argo-rollouts-canary.yaml
# kubectl delete deployment backend -n indigopay
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: backend
namespace: stellar-indigopay
labels:
app: backend
spec:
replicas: 2
revisionHistoryLimit: 5
selector:
matchLabels:
app: backend
strategy:
canary:
canaryService: backend-svc
stableService: backend-svc
steps:
- setWeight: 20
- pause: { duration: 5m }
- setWeight: 50
- pause: { duration: 5m }
- setWeight: 100
analysis:
templates:
- templateName: backend-success-rate
startingStep: 1
# Re-run analysis on each weight step. If the template returns
# `Failed`, the rollout aborts and traffic reverts to stable.
args:
- name: service-name
value: backend-svc
template:
metadata:
labels:
app: backend
app.kubernetes.io/component: api
app.kubernetes.io/part-of: stellar-indigopay
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "4000"
prometheus.io/path: "/metrics"
spec:
terminationGracePeriodSeconds: 35
containers:
- name: backend
image: stellar-indigopay/backend:latest
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 4000
protocol: TCP
envFrom:
- configMapRef:
name: stellar-indigopay-config
- secretRef:
name: stellar-indigopay-secrets
startupProbe:
httpGet:
path: /api/health
port: http
initialDelaySeconds: 1
periodSeconds: 1
failureThreshold: 30
livenessProbe:
httpGet:
path: /api/health
port: http
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3
readinessProbe:
httpGet:
path: /api/readyz
port: http
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 3
lifecycle:
preStop:
exec:
command: ["sh", "-c", "sleep 5"]
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "512Mi"
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: backend-success-rate
namespace: stellar-indigopay
spec:
args:
- name: service-name
metrics:
- name: http-success-rate
interval: 60s
count: 5
successCondition: result[0] >= 0.99
failureLimit: 2
provider:
prometheus:
address: http://prometheus-operated.monitoring.svc:9090
query: |
sum(rate(http_requests_total{job="stellar-indigopay-backend",status_code!~"5.."}[2m]))
/
sum(rate(http_requests_total{job="stellar-indigopay-backend"}[2m]))