首页 > 其他分享 >Argo Rollouts AnalysisTemplate CRD

Argo Rollouts AnalysisTemplate CRD

时间:2023-12-26 18:05:45浏览次数:38  
标签:Rollouts service args 5m prometheus CRD total AnalysisTemplate name

AnalysisTemplate CRD

apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
  name: success-rate
spec:
  args:                   # 模板参数,模板内部引用的格式为“{{args.NAME}}”;可在调用该模板时对其赋值;
  - name: <string>
    value: <string>
    valueFrom: 
      secretKeyRef:
        name: <string>
        key: <string>
  metrics:                # 必选字段,定义用于对交付效果进行分析的指标
  - name: <string>        # 必选字段,指标名称;
    initialDelay: 5m      # 延迟特定指标分析
    interval: 5m          # 多次测试时的测试间隔时长
    consecutiveErrorLimit: <Object>
    count: <Object>       # 总共测试的次数
    failureCondition: result[0] >= 0.95  # 测试结果为“失败”的条件表达式
    # 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     # 测试结果为“成功”的条件表达式
    failureLimit: 3       # 允许的最大失败运行次数
    provider:             # 指标供应方,支持web、wavefront、skywalking、prometheus、plugin、newRelic、kayenta、job、influxdb、graphite、datadog、cloudWatch。
      prometheus:
        # Prometheus服务的访问入口
        address: http://prometheus.example.com:9090
        # 向Prometheus服务发起的查询请求(PromQL)
        query: |
          sum(irate(
            istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}",response_code!~"5.*"}[5m]
          )) /
          sum(irate(
            istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}"}[5m]
          ))
  dryRun:                        # 运行于dryRun模式的metric列表,这些metric的结果不会影响最终分析结果
  - metricName: <string>         # 指标名称
  measurementRetention:          # 测量结果历史的保留数,dryRun模式的参数也支持历史结果保留
  - metricName: <string>         # 指标名称
    limit: <integer>             # 保留数量

ClusterAnalysisTemplate CRD

Rollout 可以引用称为 ClusterAnalysisTemplate 的集群范围 AnalysisTemplate。当您想要在多个rollouts之间共享 AnalysisTemplate 时,这会很有用;在不同的命名空间中,并避免在每个命名空间中重复相同的模板。使用字段 clusterScope: true 来引用 ClusterAnalysisTemplate 而不是 AnalysisTemplate。
apiVersion: argoproj.io/v1alpha1
kind: ClusterAnalysisTemplate
metadata:
  name: success-rate
spec:
  args:                   # 模板参数,模板内部引用的格式为“{{args.NAME}}”;可在调用该模板时对其赋值;
  - name: <string>
    value: <string>
    valueFrom: 
      secretKeyRef:
        name: <string>
        key: <string>
  metrics:                # 必选字段,定义用于对交付效果进行分析的指标
  - name: <string>        # 必选字段,指标名称;
    interval: 5m          # 多次测试时的测试间隔时长
    # 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     # 测试结果为“成功”的条件表达式
    failureLimit: 3       # 允许的最大失败运行次数
    provider:             # 指标供应方,支持web、wavefront、skywalking、prometheus、plugin、newRelic、kayenta、job、influxdb、graphite、datadog、cloudWatch。
      prometheus:
        # Prometheus服务的访问入口
        address: http://prometheus.example.com:9090
        # 向Prometheus服务发起的查询请求(PromQL)
        query: |
          sum(irate(
            istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}",response_code!~"5.*"}[5m]
          )) /
          sum(irate(
            istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}"}[5m]
          ))
  dryRun:                        # 运行于dryRun模式的metric列表,这些metric的结果不会影响最终分析结果
  - metricName: <string>         # 指标名称
  measurementRetention:          # 测量结果历史的保留数,dryRun模式的参数也支持历史结果保留
  - metricName: <string>         # 指标名称
    limit: <integer>             # 保留数量

AnalysisRun CRD

配置格式与AnalysisTemplaste大致相同,所不同的是,AnalysisRun用于调用并实例化分析模板。
apiVersion: argoproj.io/v1alpha1
kind: AnalysisRun
metadata:
  name: success-rate
spec:
  args:                   # 模板参数,模板内部引用的格式为“{{args.NAME}}”;可在调用该模板时对其赋值;
  - name: <string>
    value: <string>
    valueFrom: 
      secretKeyRef:
        name: <string>
        key: <string>
  metrics:                # 必选字段,定义用于对交付效果进行分析的指标
  - name: <string>        # 必选字段,指标名称;
    interval: 5m          # 多次测试时的测试间隔时长
    # 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     # 测试结果为“成功”的条件表达式
    failureLimit: 3       # 允许的最大失败运行次数
    provider:             # 指标供应方,支持web、wavefront、skywalking、prometheus、plugin、newRelic、kayenta、job、influxdb、graphite、datadog、cloudWatch。
      prometheus:
        # Prometheus服务的访问入口
        address: http://prometheus.example.com:9090
        # 向Prometheus服务发起的查询请求(PromQL)
        query: |
          sum(irate(
            istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}",response_code!~"5.*"}[5m]
          )) /
          sum(irate(
            istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}"}[5m]
          ))
  dryRun:                        # 运行于dryRun模式的metric列表,这些metric的结果不会影响最终分析结果
  - metricName: <string>         # 指标名称
  measurementRetention:          # 测量结果历史的保留数,dryRun模式的参数也支持历史结果保留
  - metricName: <string>         # 指标名称
    limit: <integer>             # 保留数量
  terminate: <boolean>

AnalysisTemplate 示例

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: guestbook
spec:
...
  strategy:
    canary:
      analysis:
        templates:
        - templateName: success-rate
          # 引用ClusterAnalysisTemplate配置
          # clusterScope: true  
        startingStep: 2 # delay starting analysis run until setWeight: 40%
        args:
        - name: service-name
          value: guestbook-svc.default.svc.cluster.local
      steps:
      - setWeight: 20
      - pause: {duration: 10m}
      - setWeight: 40
      - pause: {duration: 10m}
      - setWeight: 60
      - pause: {duration: 10m}
      - setWeight: 80
      - pause: {duration: 10m}
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
  name: success-rate
spec:
  args:
  - name: service-name
  metrics:
  - name: success-rate
    interval: 5m
    successCondition: result[0] >= 0.95
    failureLimit: 3
    count:4
    provider:
      prometheus:
        address: http://prometheus.example.com:9090
        query: |
          sum(irate(
            istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}",response_code!~"5.*"}[5m]
          )) /
          sum(irate(
            istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}"}[5m]
          ))
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
  name: error-rate
spec:
  args:
  - name: service-name
  measurementRetention:
  - metricName: total-5xx-errors
    limit: 20
  dryRun:
  - metricName: total-5xx-errors
  metrics:
  - name: total-5xx-errors
    interval: 5m
    failureCondition: result[0] >= 10
    failureLimit: 3
    provider:
      prometheus:
        address: http://prometheus.example.com:9090
        query: |
          sum(irate(
            istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}",response_code~"5.*"}[5m]
          ))
  - name: total-4xx-errors
    interval: 5m
    failureCondition: result[0] >= 10
    failureLimit: 3
    provider:
      prometheus:
        address: http://prometheus.example.com:9090
        query: |
          sum(irate(
            istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}",response_code~"4.*"}[5m]
          ))

参考文档

https://argoproj.github.io/argo-rollouts/features/analysis/



标签:Rollouts,service,args,5m,prometheus,CRD,total,AnalysisTemplate,name
From: https://blog.51cto.com/wangguishe/8985896

相关文章

  • ArgoCD和Argo Rollouts自动化部署应用
    环境说明使用ArgoRollouts部署nginx应用:1.使用Rollout部署nginx2.采用canary部署策略3.结合Analysis进行渐进式交付4.结合IstioVirtualService进行自动化流量分割和流量迁移5.部署清单放在gitrepo中使用ArgoCD进行自动化部署:1.使用Application监视GitRepository2......
  • ArgoCD和Argo Rollouts自动化部署应用
    环境说明使用ArgoRollouts部署nginx应用:1.使用Rollout部署nginx2.采用canary部署策略3.结合Analysis进行渐进式交付4.结合IstioVirtualService进行自动化流量分割和流量迁移5.部署清单放在gitrepo中使用ArgoCD进行自动化部署:1.使用Application监视GitRepositor......
  • Argo Rollouts CRD
    ArgoRolloutsCRDapiVersion:argoproj.io/v1alpha1kind:Rolloutmetadata:name:example-rollout-canaryspec:#运行的Pod实例数量,默认为1.#Defaultsto1.replicas:5analysis:#保留成功的数量#Defaultsto5.successfulRunHistoryLimit:1......
  • Argo Rollouts Canary 基础
    ArgoRolloutsCanary概述金丝雀部署是一种部署策略,将一小部分生产流量发布到新版本的应用程序。ArgoRolloutsCanary完整配置apiVersion:argoproj.io/v1alpha1kind:Rolloutmetadata:name:example-rollout-canaryspec:#运行的Pod实例数量,默认为1.#Defaultsto......
  • Argo Rollouts 基础
    ArgoRollouts概述ArgoRollouts是一个Kubernetes控制器和一组CRD,为Kubernetes提供高级部署功能,例如蓝绿、金丝雀、金丝雀分析、experimentation和渐进式交付功能。ArgoRollouts(可选)与IngressController和服务网格集成,利用其流量治理功能在更新期间逐渐将流量转移到新版本......
  • Argo Rollouts TrafficRouting结合Istio进行Canary流量管理基础
    ArgoRolloutsTrafficRouting概述流量治理技术实现如下:1.按百分比进行流量管理(即5%的流量应流向新版本,其余流量流向稳定版本)2.基于标头的路由(即将带有特定标头的请求发送到新版本)3.镜像流量,其中所有流量都被复制并并行发送到新版本(但响应被忽略)TrafficRouting配置api......
  • 理解K8S的CRD
    CRD本身是Kubernetes内置的资源类型,全称是CustomResourceDefinition,可以通过命令查看,kubectlget查看集群内定义的CRD资源。NAMECREATEDATapps.app.o0w0o.cn2019-07-25T07:02:47Zmicroservices.app.o0w0o.cn2019-07-25T07:02:47Z在与人......
  • Argo Rollouts Canary结合Istio进行流量迁移实例
    环境说明用argorollouts金丝雀发布策略更新nginx服务。发布过程结合Isito和analysis。创建nsargo-demo#kubectlcreatensargo-demonamespace/argo-democreated启用Istio自动注入功能#kubectllabelnamespaceargo-demoistio-injection=enablednamespace/argo-d......
  • Argo Rollouts AnalysisTemplate CRD
    AnalysisTemplateCRDapiVersion:argoproj.io/v1alpha1kind:AnalysisTemplatemetadata:name:success-ratespec:args:#模板参数,模板内部引用的格式为“{{args.NAME}}”;可在调用该模板时对其赋值;-name:<string>value:<string>valu......
  • Argo Rollouts Canary 基础
    ArgoRolloutsCanary概述金丝雀部署是一种部署策略,将一小部分生产流量发布到新版本的应用程序。ArgoRolloutsCanary完整配置apiVersion:argoproj.io/v1alpha1kind:Rolloutmetadata:name:example-rollout-canaryspec:#运行的Pod实例数量,默认为1.#Defaults......