不嵌入steps中 analysis
[root@ca-k8s-master01 08-argo-rollouts]# cat 03-argo-rollouts-with-analysis.yaml
# CopyRight: MageEdu <http://www.magedu.com>
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
- name: service-name
metrics:
- name: success-rate
# NOTE: prometheus queries return results in the form of a vector.
# So it is common to access the index 0 of the returned array to obtain the value
successCondition: result[0] >= 0.95
interval: 20s
count: 3
failureLimit: 3
provider:
prometheus:
address: http://prometheus.istio-system.svc.cluster.local:9090
query: |
sum(irate(
istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}",response_code!~"5.*"}[1m]
)) /
sum(irate(
istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}"}[1m]
))
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-helloworld-with-analysis
spec:
replicas: 10
strategy:
canary:
trafficRouting:
istio:
virtualService:
name: helloworld-rollout-vsvc
routes:
- primary
destinationRule:
name: helloworld-rollout-destrule
canarySubsetName: canary
stableSubsetName: stable
analysis:
templates:
- templateName: success-rate
args:
- name: service-name
# change this value to your service name
value: spring-boot-helloworld.demo.svc.cluster.local
startingStep: 2
steps:
- setWeight: 5
- pause: {duration: 1m}
- setWeight: 10
- pause: {duration: 1m}
- setWeight: 30
- pause: {duration: 1m}
- setWeight: 60
- pause: {duration: 1m}
revisionHistoryLimit: 5
selector:
matchLabels:
app: spring-boot-helloworld
template:
metadata:
labels:
app: spring-boot-helloworld
spec:
containers:
- name: spring-boot-helloworld
image: ikubernetes/spring-boot-helloworld:v0.9.2
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
requests:
memory: 32Mi
cpu: 50m
livenessProbe:
httpGet:
path: '/'
port: 80
scheme: HTTP
readinessProbe:
httpGet:
path: '/'
port: 80
scheme: HTTP
initialDelaySeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: spring-boot-helloworld
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: spring-boot-helloworld
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: helloworld-rollout-vsvc
spec:
#gateways:
#- istio-rollout-gateway
hosts:
- spring-boot-helloworld
http:
- name: primary
route:
- destination:
host: spring-boot-helloworld
subset: stable
weight: 100
- destination:
host: spring-boot-helloworld
subset: canary
weight: 0
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: helloworld-rollout-destrule
spec:
host: spring-boot-helloworld
subsets:
- name: canary
labels:
app: spring-boot-helloworld
- name: stable
labels:
app: spring-boot-helloworld
---
嵌入在steps 中的analysis
[root@ca-k8s-master01 08-argo-rollouts]# cat 04-argo-rollouts-with-analysis.yaml
# CopyRight: MageEdu <http://www.magedu.com>
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
- name: service-name
metrics:
- name: success-rate
# NOTE: prometheus queries return results in the form of a vector.
# So it is common to access the index 0 of the returned array to obtain the value
successCondition: result[0] >= 0.95
interval: 20s
count: 3
failureLimit: 3
provider:
prometheus:
address: http://prometheus.istio-system.svc.cluster.local:9090
query: |
sum(irate(
istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}",response_code!~"5.*"}[1m]
)) /
sum(irate(
istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}"}[1m]
))
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-helloworld-with-analysis
spec:
replicas: 10
strategy:
canary:
trafficRouting:
istio:
virtualService:
name: helloworld-rollout-vsvc
routes:
- primary
destinationRule:
name: helloworld-rollout-destrule
canarySubsetName: canary
stableSubsetName: stable
steps:
- setWeight: 5
- pause: {duration: 2m}
- analysis:
templates:
- templateName: success-rate
args:
- name: service-name
value: spring-boot-helloworld.demo.svc.cluster.local
- setWeight: 10
- pause: {duration: 1m}
- setWeight: 30
- pause: {duration: 1m}
- setWeight: 60
- pause: {duration: 1m}
revisionHistoryLimit: 5
selector:
matchLabels:
app: spring-boot-helloworld
template:
metadata:
labels:
app: spring-boot-helloworld
spec:
containers:
- name: spring-boot-helloworld
image: ikubernetes/spring-boot-helloworld:v0.9.2
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
requests:
memory: 32Mi
cpu: 50m
livenessProbe:
httpGet:
path: '/'
port: 80
scheme: HTTP
readinessProbe:
httpGet:
path: '/'
port: 80
scheme: HTTP
initialDelaySeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: spring-boot-helloworld
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: spring-boot-helloworld
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: helloworld-rollout-vsvc
spec:
#gateways:
#- istio-rollout-gateway
hosts:
- spring-boot-helloworld
http:
- name: primary
route:
- destination:
host: spring-boot-helloworld
subset: stable
weight: 100
- destination:
host: spring-boot-helloworld
subset: canary
weight: 0
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: helloworld-rollout-destrule
spec:
host: spring-boot-helloworld
subsets:
- name: canary
labels:
app: spring-boot-helloworld
- name: stable
labels:
app: spring-boot-helloworld
---