Skip to content

Commit 9e00b5c

Browse files
committedNov 1, 2024
Add canary and blue-green analysisTemplates
1 parent eaa6cbe commit 9e00b5c

File tree

5 files changed

+92
-95
lines changed

5 files changed

+92
-95
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: AnalysisTemplate
3+
metadata:
4+
name: success-rate-post ######## post-promotion-analysis
5+
spec:
6+
args:
7+
- name: service-port
8+
value: "5000"
9+
- name: service-namespace
10+
metrics:
11+
- name: success-rate-post
12+
provider:
13+
job:
14+
metadata:
15+
labels:
16+
analysis: post-promotion # labels defined here will be copied to the Job object
17+
spec:
18+
backoffLimit: 0
19+
template:
20+
spec:
21+
containers:
22+
- name: success-rate-post
23+
image: analysis
24+
imagePullPolicy: Never
25+
env:
26+
- name: service_url
27+
value: "http://rollout-bluegreen-active.{{args.service-namespace}}.svc.cluster.local:{{args.service-port}}"
28+
command: ["/bin/bash", "-c"]
29+
args:
30+
- ./app-success-rate.sh
31+
restartPolicy: Never
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: AnalysisTemplate
3+
metadata:
4+
name: success-rate-pre ######## pre-promotion-analysis
5+
spec:
6+
args:
7+
- name: service-port
8+
value: "5000"
9+
- name: service-namespace
10+
metrics:
11+
- name: success-rate-pre
12+
provider:
13+
job:
14+
metadata:
15+
labels:
16+
analysis: pre-promotion # labels defined here will be copied to the Job object
17+
spec:
18+
backoffLimit: 0
19+
template:
20+
spec:
21+
containers:
22+
- name: success-rate-pre
23+
image: analysis ##### this is the same image that we built to get success_rate . you can find related files (Dockerfile, app-success-rate.sh) in the current directory
24+
imagePullPolicy: Never
25+
env:
26+
- name: service_url
27+
value: "http://rollout-bluegreen-preview.{{args.service-namespace}}.svc.cluster.local:{{args.service-port}}"
28+
command: ["/bin/bash", "-c"]
29+
args:
30+
- ./app-success-rate.sh
31+
restartPolicy: Never

‎v14-argo-rollouts-analysis/blue-green-analysis/rollout-with-analysis.yml

+7-71
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,4 @@
11
apiVersion: argoproj.io/v1alpha1
2-
kind: AnalysisTemplate
3-
metadata:
4-
name: success-rate-pre ######## pre-promotion-analysis
5-
spec:
6-
args:
7-
- name: service-port
8-
value: "5000"
9-
- name: service-namespace
10-
metrics:
11-
- name: success-rate-pre
12-
provider:
13-
job:
14-
metadata:
15-
labels:
16-
analysis: pre-promotion # labels defined here will be copied to the Job object
17-
spec:
18-
backoffLimit: 0
19-
template:
20-
spec:
21-
containers:
22-
- name: success-rate-pre
23-
image: analysis ##### this is the same image that we built to get success_rate . you can find related files (Dockerfile, app-success-rate.sh) in the current directory
24-
imagePullPolicy: Never
25-
env:
26-
- name: service_url
27-
value: "http://rollout-bluegreen-preview.{{args.service-namespace}}.svc.cluster.local:{{args.service-port}}"
28-
command: ["/bin/bash", "-c"]
29-
args:
30-
- ./app-success-rate.sh
31-
restartPolicy: Never
32-
---
33-
apiVersion: argoproj.io/v1alpha1
34-
kind: AnalysisTemplate
35-
metadata:
36-
name: success-rate-post ######## post-promotion-analysis
37-
spec:
38-
args:
39-
- name: service-port
40-
value: "5000"
41-
- name: service-namespace
42-
metrics:
43-
- name: success-rate-post
44-
provider:
45-
job:
46-
metadata:
47-
labels:
48-
analysis: post-promotion # labels defined here will be copied to the Job object
49-
spec:
50-
backoffLimit: 0
51-
template:
52-
spec:
53-
containers:
54-
- name: success-rate-post
55-
image: analysis
56-
imagePullPolicy: Never
57-
env:
58-
- name: service_url
59-
value: "http://rollout-bluegreen-active.{{args.service-namespace}}.svc.cluster.local:{{args.service-port}}"
60-
command: ["/bin/bash", "-c"]
61-
args:
62-
- ./app-success-rate.sh
63-
restartPolicy: Never
64-
---
65-
apiVersion: argoproj.io/v1alpha1
662
kind: Rollout
673
metadata:
684
name: blue-green-deployment
@@ -90,18 +26,18 @@ spec:
9026
activeService: rollout-bluegreen-active
9127
previewService: rollout-bluegreen-preview
9228
autoPromotionEnabled: true
93-
prePromotionAnalysis:
29+
prePromotionAnalysis: #### Pre-Promotion Analysis
9430
templates:
9531
- templateName: success-rate-pre
9632
args:
9733
- name: service-namespace
9834
value: blue-green
99-
postPromotionAnalysis:
100-
templates:
101-
- templateName: success-rate-post
102-
args:
103-
- name: service-namespace
104-
value: blue-green
35+
# postPromotionAnalysis: #### Post-Promotion Analysis
36+
# templates:
37+
# - templateName: success-rate-post
38+
# args:
39+
# - name: service-namespace
40+
# value: blue-green
10541
# abortScaleDownDelaySeconds: 10
10642
# scaleDownDelaySeconds: 60
10743
# previewReplicaCount: 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: AnalysisTemplate
3+
metadata:
4+
name: success-rate
5+
spec:
6+
args:
7+
- name: service_address ### This is the variable related to the ip address where the analysis-app.py is located
8+
value: "192.168.1.5" #### WE are using a flask script to get the url of the application and try to connect to it 5 times at 5 seconds intervals and returns one of the true or false values based on "200 response_code" in a json format, if the success_rate is 80% or more , it returns "true" value, Otherwise it returns "false" value, you can find this simple app in the current directory (its name is analysis-app.py).
9+
- name: service_port ### This is the variable related to the port of analysis-app.py flask app
10+
metrics:
11+
- name: success-rate
12+
successCondition: result == "true"
13+
provider:
14+
web:
15+
method: POST
16+
url: "http://{{args.service_address}}:{{args.service_port}}/measure_success_rate" #### The url related to the analysis-app.py flask app
17+
timeoutSeconds: 50 # defaults to 10 seconds
18+
headers:
19+
- key: Content-Type # if body is a json, it is recommended to set the Content-Type
20+
value: "application/json"
21+
jsonBody: # If using jsonBody Content-Type header will be automatically set to json
22+
url: "http://rollouts-setweight.demo"
23+
jsonPath: "{$.data.ok}"

‎v14-argo-rollouts-analysis/canary-analysis/rollout-with-analysis.yml

-24
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
11
apiVersion: argoproj.io/v1alpha1
2-
kind: AnalysisTemplate
3-
metadata:
4-
name: success-rate
5-
spec:
6-
args:
7-
- name: service_address ### This is the variable related to the ip address where the analysis-app.py is located
8-
value: "192.168.1.4" #### WE are using a flask script to get the url of the application and try to connect to it 5 times at 5 seconds intervals and returns one of the true or false values based on "200 response_code" in a json format, if the success_rate is 80% or more , it returns "true" value, Otherwise it returns "false" value, you can find this simple app in the current directory (its name is analysis-app.py).
9-
- name: service_port ### This is the variable related to the port of analysis-app.py flask app
10-
metrics:
11-
- name: success-rate
12-
successCondition: result == "true"
13-
provider:
14-
web:
15-
method: POST
16-
url: "http://{{args.service_address}}:{{args.service_port}}/measure_success_rate" #### The url related to the analysis-app.py flask app
17-
timeoutSeconds: 50 # defaults to 10 seconds
18-
headers:
19-
- key: Content-Type # if body is a json, it is recommended to set the Content-Type
20-
value: "application/json"
21-
jsonBody: # If using jsonBody Content-Type header will be automatically set to json
22-
url: "http://rollouts-setweight.demo"
23-
jsonPath: "{$.data.ok}"
24-
---
25-
apiVersion: argoproj.io/v1alpha1
262
kind: Rollout
273
metadata:
284
name: rollouts-setweight

0 commit comments

Comments
 (0)
Please sign in to comment.