首页 > 其他分享 >argo-rollouts结合Istio进行Canary流行迁移

argo-rollouts结合Istio进行Canary流行迁移

时间:2022-11-14 10:44:53浏览次数:52  
标签:name rollouts spring boot Istio helloworld istio Canary

 给default打标签,让pod自动注入istio sidecar

[root@master 08-argo-rollouts]# kubectl label namespace default istio-injection=enabled
namespace/default labeled
[root@master 08-argo-rollouts]# kubectl apply -f 02-argo-rollouts-with-istio-traffic-shifting.yaml 
rollout.argoproj.io/rollouts-helloworld-with-traffic-shifting created
service/spring-boot-helloworld unchanged
virtualservice.networking.istio.io/helloworld-rollout-vsvc created
destinationrule.networking.istio.io/helloworld-rollout-destrule created
[root@master 08-argo-rollouts]# cat 02-argo-rollouts-with-istio-traffic-shifting.yaml 
# CopyRight: MageEdu <[email protected]>
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollouts-helloworld-with-traffic-shifting
spec:
  replicas: 10 
  strategy:
    canary:
      trafficRouting:
        istio:
          virtualService: 
            name: helloworld-rollout-vsvc        # required
            routes:
            - primary                 # optional if there is a single route in VirtualService, required otherwise
          destinationRule:
            name: helloworld-rollout-destrule    # required
            canarySubsetName: canary  # required
            stableSubsetName: stable  # required
      steps:
      - setCanaryScale:
          matchTrafficWeight: true
      - setWeight: 5
      - pause: {duration: 1m}
      - setWeight: 10
      - pause: {duration: 1m}
      - pause: {duration: 20}
      - setWeight: 20
      - pause: {duration: 40}
      - setWeight: 40
      - pause: {duration: 20}
      - setWeight: 60
      - pause: {duration: 20}
      - setWeight: 80
      - pause: {duration: 20}
  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
          initialDelaySeconds: 3
        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       # referenced in canary.trafficRouting.istio.virtualService.routes
    route:
    - destination:
        host: spring-boot-helloworld
        subset: stable  # referenced in canary.trafficRouting.istio.destinationRule.stableSubsetName
      weight: 100
    - destination:
        host: spring-boot-helloworld
        subset: canary  # referenced in canary.trafficRouting.istio.destinationRule.canarySubsetName
      weight: 0
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: helloworld-rollout-destrule
spec:
  host: spring-boot-helloworld
  subsets:
  - name: canary   # referenced in canary.trafficRouting.istio.destinationRule.canarySubsetName
    labels:        # labels will be injected with canary rollouts-pod-template-hash value
      app: spring-boot-helloworld
  - name: stable   # referenced in canary.trafficRouting.istio.destinationRule.stableSubsetName
    labels:        # labels will be injected with stable rollouts-pod-template-hash value
      app: spring-boot-helloworld
---
[root@master 08-argo-rollouts]# kubectl get vs
NAME                      GATEWAYS   HOSTS                        AGE
helloworld-rollout-vsvc              ["spring-boot-helloworld"]   15m

 

可以看到canary权重为0,stable权重为100

[root@master 08-argo-rollouts]# kubectl get vs helloworld-rollout-vsvc -o yaml -w
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"networking.istio.io/v1beta1","kind":"VirtualService","metadata":{"annotations":{},"name":"helloworld-rollout-vsvc","namespace":"default"},"spec":{"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}]}]}}
  creationTimestamp: "2022-11-14T02:02:32Z"
  generation: 1
  name: helloworld-rollout-vsvc
  namespace: default
  resourceVersion: "1613040"
  uid: e5e693fd-0b56-4e2a-b386-78a3a010230d
spec:
  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

访问测试都是旧版本0.9.2

把image版本改成0.9.3,再apply

[root@master 08-argo-rollouts]# 02-argo-rollouts-with-istio-traffic-shifting.yaml 
    spec:
      containers:
      - name: spring-boot-helloworld
        image: ikubernetes/spring-boot-helloworld:v0.9.3
[root@master 08-argo-rollouts]# kubectl apply -f 02-argo-rollouts-with-istio-traffic-shifting.yaml 
rollout.argoproj.io/rollouts-helloworld-with-traffic-shifting configured
service/spring-boot-helloworld unchanged
virtualservice.networking.istio.io/helloworld-rollout-vsvc unchanged
destinationrule.networking.istio.io/helloworld-rollout-destrule configured

第一次权重是5,第二次权重是10

全部更新完

标签:name,rollouts,spring,boot,Istio,helloworld,istio,Canary
From: https://www.cnblogs.com/zyyang1993/p/16888237.html

相关文章

  • 部署argo-rollouts
    https://github.com/argoproj/argo-rollouts/releaseskubectlcreatenamespaceargo-rolloutskubectlapply-nargo-rollouts-fhttps://github.com/argoproj/argo-ro......
  • servicemesh及istio
    ServiceMesh以及Sidecar在介绍ServiceMesh概念之前,我们先来了解一下Sidecar。Sidecar是以第一次世界大战时活跃在战场上的军用边斗车命名(也是我们在抗日神剧中最常见的道......
  • Istio代理级指标
    代理级指标Envoy会生成其资源级别(例如Listener、Cluster等)的指标获取Envoy统计信息的常用方式有两程AdminInterface的/stats或/stats/prometheus用于接收统计......
  • Istio可观测性
    可观测性应用日志、指标和跟踪是应用程序可观测性的三大支柱,前二者更多的是属于传统的“以主机为中心”的模型,而跟踪则“以流程为中心”日志:日志是随时间发生的离散事......
  • 使用 Istioctl 安装 istio
    使用Istioctl安装istio下载Istio转到Istio发布页面,下载针对你操作系统的安装文件,或用自动化工具下载并提取最新版本(Linux或macOS):[root@k8s-master-node1~]#curl......
  • ingress-istio配置服务
    文档说明:只记录关键地方;试验环境:linuxdebian11目标:自建K8S对外提供httphttps服务ingress-istio暴露服务端口暴露80和443端口apiVersion:v1kind:Se......
  • Istio典型应用场景
    Istio作为服务治理的工具,使用户不需要在项目中编写代码即可实现微服务治理。主要应用分布式调用追踪、遥测度量收集、灰度发布应用、熔断、故障注入等几个方面场景。Istio......
  • Istio架构设计有4大关键目标
     Istio作为服务网格技术的代表作,通过sidecar代理拦截了微服务之间的所有网络通信,用统一方式实现服务之间的负载均衡、访问控制、速率限制等功能。应用无须了解底层服务访......
  • Istio egress gateway
    EgressGateway逻辑示意图EgressGateway配置要点各SidecarEnvoy上访问特定外部主机的流量,要路由至EgressGatewayEgressGateway要将相应的流量路由至相应的外部......
  • Istio workloadEntry实例
    服务说明在网格外部运行有nginx服务,有两个实例Nginx2001:监听地址为172.29.1.201:8091,Nginx版本为1.20Nginx2002:监听地址为172.29.1.202:8091,Nginx版本为1.20N......