flagger集成istio自动完成ABTesting部署

介绍

接着上一篇文章:flagger集成istio自动完成金丝雀部署

这边文章主要讲A/B Testing

A/B 发布主要是根据特定的条件将一部分匹配规则的用户匹配到新版本 其他还是使用老板的部署

请求头满足谷歌和Safari浏览器的用户:regex: “^(?!.Chrome).*Safari.

请求cookie中包含type=insider的用户:regex: “^(.?;)?(type=insider)(;.)?$”

所有的部署最好是在app新版之前发布验证是否会影响老用户部署的,千万别再app新版发布后发布接口,这样可能会导致接口404的情况的所以要注意的哟

部署

服务啊网关啊都用上一篇文章的

vi abtest.yaml

apiVersion: flagger.app/v1alpha3
kind: Canary
metadata:
  name: podinfo
  namespace: test
spec:
  # deployment reference
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: podinfo
  # the maximum time in seconds for the canary deployment
  # to make progress before it is rollback (default 600s)
  progressDeadlineSeconds: 60
  # HPA reference (optional)
  autoscalerRef:
    apiVersion: autoscaling/v2beta1
    kind: HorizontalPodAutoscaler
    name: podinfo
  service:
    # container port
    port: 8081
    # Istio gateways (optional)
    gateways:
    - public-gateway.istio-system.svc.cluster.local
    # Istio virtual service host names (optional)
    hosts:
    - app.ciwei.com
  canaryAnalysis:
    # schedule interval (default 60s)
    interval: 1m
    # total number of iterations
    iterations: 10
    # max number of failed iterations before rollback
    threshold: 2
    # canary match condi condiion
    match:
      - headers:
          user-agent:
            regex: "^(?!.*Chrome).*Safari.*"
      - headers:
          cookie:
            regex: "^(.*?;)?(type=insider)(;.*)?$"
    metrics:
    - name: request-success-rate
      # minimum req success rate (non 5xx responses)
      # percentage (0-100)
      threshold: 99
      interval: 1m
    - name: request-duration
      # maximum req duration P99
      # milliseconds
      threshold: 500
      interval: 30s

kubectl create -f abtest.yaml

升级镜像版本

模拟升级发布

kubectl -n test set image deployment/podinfo podinfod=demo:2.0

访问:app.ciwei.com/walle 模拟流量呀

查看发布情况

kubectl -n istio-system logs deployment/flagger -f | jq .msg

"Initialization done! podinfo.test"
"Synced test/podinfo"
"VirtualService podinfo.test updated"
"New revision detected! Scaling up podinfo.test"
"Starting canary analysis for podinfo.test"
"Advance podinfo.test canary iteration 1/10"
"Advance podinfo.test canary iteration 2/10"
"Advance podinfo.test canary iteration 3/10"
"Advance podinfo.test canary iteration 4/10"
"Advance podinfo.test canary iteration 5/10"
"Advance podinfo.test canary iteration 6/10"
"Advance podinfo.test canary iteration 7/10"
"Advance podinfo.test canary iteration 8/10"
"Advance podinfo.test canary iteration 9/10"
"Advance podinfo.test canary iteration 10/10"
"Copying podinfo.test template spec to podinfo-primary.test"
"HorizontalPodAutoscaler podinfo-primary.test updated"
"Halt advancement podinfo-primary.test waiting for rollout to finish: 1 old replicas are pending termination"
"Promotion completed! Scaling down podinfo.test"

这个发布主要是根据过滤条件控制部分用户或者部分浏览行为访问新版本其他访问老版本实现的部署呀


文章作者: Ciwei
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Ciwei !
 上一篇
hexo-theme-butterfly主题安装呀 hexo-theme-butterfly主题安装呀
快速开始hexo-theme-butterfly是基于Molunerfinn的hexo-theme-melody的基础上进行开发的。文档也是在hexo-theme-melody的文档基础上修改。因为一些配置变更导致与原主题配置上有部分区别。
2019-07-04
下一篇 
flagger集成istio自动完成蓝绿部署 flagger集成istio自动完成蓝绿部署
介绍接着上一篇文章:flagger集成istio自动完成金丝雀部署 这边文章主要讲蓝绿部署 所有的部署最好是在app新版之前发布验证是否会影响老用户部署的,千万别再app新版发布后发布接口,这样可能会导致接口404的情况的所以要注意的哟
2019-07-01
  目录