当前位置: 首页 > news >正文

备考ICA----Istio实验4---使用 Istio 进行金丝雀部署

备考ICA----Istio实验4—使用 Istio 进行金丝雀部署

上一个实验已经通过DestinationRule实现了部分金丝雀部署的功能,这个实验会更完整的模拟展示一个环境由v1慢慢过渡到v2版本的金丝雀发布.

1. 环境清理

kubectl delete gw/helloworld-gateway vs/helloworld dr/helloworld-destination

测试

kubectl get svc,pods
for i in {1..10};do curl $(kubectl get svc helloworld|grep helloworld|awk '{print $3":"$5}'|awk -F"/" '{print $1"/hello"}');sleep .5 ;done
kubectl get gw,vs,dr

在这里插入图片描述
恢复到这样就可以通过helloworld的svc将流量随机分配到v1和v2上
如果实验环境有问题,就重新部署hello

kubectl delete -f istio/samples/helloworld/helloworld.yaml
kubectl apple -f istio/samples/helloworld/helloworld.yaml

2. 所有流量转发到v1

这步就模拟只存在1个版本的环境
canary/helloworld-canary-all-v1.yaml

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:name: helloworld-gateway
spec:selector:istio: ingressgateway # use istio default controllerservers:- port:number: 80name: httpprotocol: HTTPhosts:- "*"
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:name: helloworld-destination
spec:host: helloworldsubsets:- name: v1labels:version: v1- name: v2labels:version: v2
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:name: helloworld
spec:hosts:- "*"gateways:- helloworld-gatewayhttp:- match:- uri:exact: /helloroute:- destination:host: helloworldport:number: 5000subset: v1weight: 100

部署gw,vs,dr

kubectl apply -f canary/helloworld-canary-all-v1.yaml

测试效果
此时所有流量都交由v1进行响应

for i in {1..10};do curl http://192.168.126.220/hello;sleep .5;done

在这里插入图片描述
在这里插入图片描述

3. 90%流量v1,10%流量v2

此时v2版本应用已经上线,将10%流量给v2,其余流量仍由v1进行应答

3.1 配置流量分发比例

canary/helloworld-canary-allin1-10v2.yaml

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:name: helloworld-gateway
spec:selector:istio: ingressgateway # use istio default controllerservers:- port:number: 80name: httpprotocol: HTTPhosts:- "*"
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:name: helloworld-destination
spec:host: helloworldsubsets:- name: v1labels:version: v1- name: v2labels:version: v2
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:name: helloworld
spec:hosts:- "*"gateways:- helloworld-gatewayhttp:- match:- uri:exact: /helloroute:- destination:host: helloworldport:number: 5000subset: v1weight: 90- destination:host: helloworldport:number: 5000subset: v2weight: 10

部署gw,vs,dr

kubectl apply -f canary/helloworld-canary-allin1-10v2.yaml 

测试效果
可以看到10个请求中有1个由v2应答,其他仍由v1进行响应
在这里插入图片描述
在这里插入图片描述

3.2 加入Hpa

---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:name: hpa-helloworld-v1
spec:maxReplicas: 20minReplicas: 1scaleTargetRef:apiVersion: apps/v1kind: Deploymentname: helloworld-v1targetCPUUtilizationPercentage: 50
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:name: hpa-helloworld-v2
spec:maxReplicas: 20minReplicas: 1scaleTargetRef:apiVersion: apps/v1kind: Deploymentname: helloworld-v2targetCPUUtilizationPercentage: 50

部署hpa

kubectl apply -f canary/hpa.yaml

3.3 压测

 while true;do curl http://192.168.126.220/hello;done

产生大量请求
在这里插入图片描述

此时v1,v2因访问量大触发hpa扩容,直到v1到达上线16个pod,v2到达3个

在这里插入图片描述

4. 50%流量v1,50%流量v2

4.1 配置流量分发比例

dr和gw部分就不用动了.只要修改vs的weight部分就可以
canary/helloworld-canary-vs-50v2.yaml

---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:name: helloworld
spec:hosts:- "*"gateways:- helloworld-gatewayhttp:- match:- uri:exact: /helloroute:- destination:host: helloworldport:number: 5000subset: v1weight: 50- destination:host: helloworldport:number: 5000subset: v2weight: 50

部署

kubectl apply -f canary/helloworld-canary-vs-50v2.yaml

4.2 压测

此时流量以1:1分发给v1和v2
在这里插入图片描述

再观测hpa的情况会发现v2的cpu逐渐升高,v1的cpu逐渐降低,v2开始扩容,v1开始缩容,逐渐扩缩容到10:10
在这里插入图片描述
在这里插入图片描述

5. 所有流量转发v2

51. 配置流量分发比例

中间的10%,90%其实和前2个版本差不多,直接修改下数值就可以了.我们这里就忽略了,有兴趣的老哥可以进一步的修改模拟.
这里就模拟经过测试v2版本已经没有问题,我们将所有流量打到v2上
canary/helloworld-canary-all-v2.yaml

---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:name: helloworld
spec:hosts:- "*"gateways:- helloworld-gatewayhttp:- match:- uri:exact: /helloroute:- destination:host: helloworldport:number: 5000subset: v2weight: 100

部署

kubectl apply -f canary/helloworld-canary-all-v2.yaml

5.2 压测

while true;do curl http://192.168.126.220/hello;done

在这里插入图片描述
在这里插入图片描述
至此canary的一个模拟从v1到v2的版本切换就已经完成了

6. 拓展Canary+AB测试

6.1 canary+ab配置

当我们进行canary测试的时候,普通用户是以50%:50%的流量分发到2个版本上,但我们希望测试人员trump同学,每次都是访问到新上线的v2版本上.
canary/canary-ab-vs.yaml

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:name: helloworld
spec:hosts:- "*"gateways:- helloworld-gatewayhttp:- match:- headers:user:exact: trumpuri:exact: /helloroute:- destination:host: helloworldport:number: 5000subset: v2weight: 100- route:- destination:host: helloworldport:number: 5000subset: v1weight: 50- destination:host: helloworldport:number: 5000subset: v2weight: 50

部署应用

kubectl apply -f canary/canary-ab-vs.yaml

在这里插入图片描述

6.2 测试

6.2.1 普通用户测试

这部分用户进准的按1:1流量访问v1和v2

for i in {1..20};do curl http://192.168.126.220/hello;done

在这里插入图片描述
在这里插入图片描述

6.2.2 测试人员访问

当测试人员trump访问时,匹配header中的用户名为trump,流量就被100%的打到v2版本上

for i in {1..20};do curl -H "user:trump" http://192.168.126.220/hello;done

在这里插入图片描述
在这里插入图片描述
至此整个金丝雀部署完成

相关文章:

备考ICA----Istio实验4---使用 Istio 进行金丝雀部署

备考ICA----Istio实验4—使用 Istio 进行金丝雀部署 上一个实验已经通过DestinationRule实现了部分金丝雀部署的功能,这个实验会更完整的模拟展示一个环境由v1慢慢过渡到v2版本的金丝雀发布. 1. 环境清理 kubectl delete gw/helloworld-gateway vs/helloworld dr/helloworld…...

LeetCode-热题100:39.组合总和

题目描述 给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target ,找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 ,并以列表形式返回。你可以按 任意顺序 返回这些组合。 candidates 中的 同一个 数字可以 无限制重复被…...

演讲嘉宾公布 | 智能家居与会议系统专题论坛将于3月28日举办

一、智能家居与会议系统专题论坛 智能家居通过集成先进的技术和设备,为人们提供了更安全、舒适、高效、便捷且多彩的生活体验。智能会议系统它通过先进的技术手段,提高了会议效率,降低了沟通成本,提升了参会者的会议体验。对于现代…...

Unity发布webgl之后打开PDF文件,不使用js,不和浏览器交互

创建一个按钮,然后点击就会打开 在webgl下要使用这样的路径拼接,不然就会报错。 btnBook.onClick.AddListener(() >{var uri new System.Uri(Path.Combine(Application.streamingAssetsPath "/Books", "文档.pdf"));Debug.Log…...

Python之装饰器-无参装饰器

Python之装饰器-无参装饰器 装饰器介绍 1. 为何要用装饰器 Python 中的装饰器是一种语法糖,可以在运行时,动态的给函数或类添加功能。装饰器本质上是一个函数,使用 函数名就是可实现绑定给函数的第二个功能 。将一些通用的、特定函数的功…...

音视频实战--音视频编码

1、查找所需的编码器–avcodec_find_encoder或avcodec_find_encoder_by_name 音频编码和视频编码流程基本相同,使用音频编码器则可以编码音频数据,使用视频编码器则可以编码视频数据。 /* 指定的编码器 ID 查找对应的编码器。可以通过这个函数来获取特…...

【黄金手指】windows操作系统环境下使用jar命令行解压和打包Springboot项目jar包

一、背景 项目中利用maven将Springboot项目打包成生产环境jar包。名为 prod_2024_1.jar。 需求是 修改配置文件中的某些参数值,并重新发布。 二、解压 jar -xvf .\prod_2024_1.jar释义: 这段命令是用于解压缩名为"prod_2024_1.jar"的Java归…...

React【Day1】

B站视频链接 一、React介绍 React由Meta公司开发,是一个用于 构建Web和原生交互界面的库 React的优势 相较于传统基于DOM开发的优势 组件化的开发方式不错的性能 相较于其它前端框架的优势 丰富的生态跨平台支持 React的市场情况 全球最流行,大…...

MNN 执行推理(九)

系列文章目录 MNN createFromBuffer(一) MNN createRuntime(二) MNN createSession 之 Schedule(三) MNN createSession 之创建流水线后端(四) MNN Session 之维度计算(五…...

算法公式汇总

文章目录 三角函数定义式诱导公式平方关系两角和与差的三角函数积化和差公式和差化积公式倍角公式半角公式万能公式其他公式反三角函数恒等式 三角函数定义式 三角函数 定义式 余切: c o t A 1 t a n A \text { 余切:} \ cotA \frac{1}{tanA} 余切&a…...

c语言管理课程信息系统

定制魏:QTWZPW,获取更多源码等 目录 题目要求 数据结构 函数设计 结构设计 管理员功能: 学生功能: 效果展示 总结 主函数代码 题目要求 管理课程信息系统,允许管理员和学生执行不同的操作。管理员可以添加、浏览、查询、删除、修改和排序课程信息。学生可以…...

大模型在天体物理学研究中的辅助作用与案例分析

大模型在天体物理学研究中的辅助作用与案例分析 1. 背景介绍 天体物理学是研究宇宙中各种天体的物理性质和运动规律的科学。随着观测技术的进步,天体物理学家们获得了大量的数据,这些数据往往具有高维度、非线性、非平稳等特点,给传统的数据…...

洛谷_P1873 [COCI 2011/2012 #5] EKO / 砍树_python写法

P1873 [COCI 2011/2012 #5] EKO / 砍树 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) n, m map(int,input().split())data list(map(int,input().split())) h 0 def check(mid):h 0for i in data:if i>mid:h (i-mid)if h < m:return Trueelse:return Falsel 0 r …...

Android_NDK调试

第一步&#xff1a; 链接log动态库 在Android.mk文件中添加 LOCAL_LDLIBS -llog 注意&#xff1a;一定要在 include $(BUILD_SHARED_LIBRARY) 之上添加&#xff0c;因为当执行到这句话的时候就表示所有的lib动态库已经加载完毕了&#xff0c;所以当你在这句代码之后再添加…...

全量知识系统 概要设计(SmartChat回复)

以下是根据我给出的 系统概要 “提要和纪要”&#xff0c;SmartChat给出的概要设计。我给出的“提要和纪要”可参考链接&#xff1a; https://blog.csdn.net/ChuanfangChen/article/details/136861822 -------------------------------- 概要设计文档 1. 简介 全量知识系统…...

一、SpringBoot基础搭建

本教程主要给初学SpringBoot的开发者&#xff0c;通过idea搭建单体服务提供手把手教学例程&#xff0c;主要目的在于理解环境的搭建&#xff0c;以及maven模块之间的整合与调用 源码&#xff1a;jun/learn-springboot 以商城项目为搭建例子&#xff0c;首先计划建1个父模块&…...

some/ip CAN CANFD

关于SOME/IP的理解 在CAN总线的车载网络中&#xff0c;通信过程是面向信号的 当ECU的信号的值发生了改变&#xff0c;或者发送周期到了&#xff0c;就会发送消息&#xff0c;而不考虑接收者是否需要&#xff0c;这样就会造成总线上出现不必要的信息&#xff0c;占用了带宽 …...

HTTP Header Fields

HTTP&#xff08;超文本传输协议&#xff09;中包含多种类型的头部字段&#xff08;Header Fields&#xff09;&#xff0c;以下是常见的HTTP头部字段及其作用&#xff1a; ### 通用头字段&#xff08;General Header Fields&#xff09; - **Cache-Control**: 控制缓存行为&a…...

基于FPGA的FFT图像滤波设计

1.FFT滤波算法介绍 FFT滤波就是通过傅里叶运算将图像转换到频域空间&#xff0c;然后在频域中对图像进行处理&#xff0c;最后将处理后的图像通过傅里叶逆运算将图像转会到时域空间。 在频域空间中&#xff0c;我们能够更好的对图像的噪声进行分析&#xff0c;然后找出相关规律…...

WPF 立体Border

WPF 立体Border &#xff0c;用来划分各个功能区块 在资源文件中&#xff0c;添加如下样式代码&#xff1a; <Style x:Key"BaseBorder" TargetType"Border"><Setter Property"Background" Value"White" /><Setter Prop…...

铭豹扩展坞 USB转网口 突然无法识别解决方法

当 USB 转网口扩展坞在一台笔记本上无法识别,但在其他电脑上正常工作时,问题通常出在笔记本自身或其与扩展坞的兼容性上。以下是系统化的定位思路和排查步骤,帮助你快速找到故障原因: 背景: 一个M-pard(铭豹)扩展坞的网卡突然无法识别了,扩展出来的三个USB接口正常。…...

挑战杯推荐项目

“人工智能”创意赛 - 智能艺术创作助手&#xff1a;借助大模型技术&#xff0c;开发能根据用户输入的主题、风格等要求&#xff0c;生成绘画、音乐、文学作品等多种形式艺术创作灵感或初稿的应用&#xff0c;帮助艺术家和创意爱好者激发创意、提高创作效率。 ​ - 个性化梦境…...

C++:std::is_convertible

C++标志库中提供is_convertible,可以测试一种类型是否可以转换为另一只类型: template <class From, class To> struct is_convertible; 使用举例: #include <iostream> #include <string>using namespace std;struct A { }; struct B : A { };int main…...

2021-03-15 iview一些问题

1.iview 在使用tree组件时&#xff0c;发现没有set类的方法&#xff0c;只有get&#xff0c;那么要改变tree值&#xff0c;只能遍历treeData&#xff0c;递归修改treeData的checked&#xff0c;发现无法更改&#xff0c;原因在于check模式下&#xff0c;子元素的勾选状态跟父节…...

leetcodeSQL解题:3564. 季节性销售分析

leetcodeSQL解题&#xff1a;3564. 季节性销售分析 题目&#xff1a; 表&#xff1a;sales ---------------------- | Column Name | Type | ---------------------- | sale_id | int | | product_id | int | | sale_date | date | | quantity | int | | price | decimal | -…...

C++ 求圆面积的程序(Program to find area of a circle)

给定半径r&#xff0c;求圆的面积。圆的面积应精确到小数点后5位。 例子&#xff1a; 输入&#xff1a;r 5 输出&#xff1a;78.53982 解释&#xff1a;由于面积 PI * r * r 3.14159265358979323846 * 5 * 5 78.53982&#xff0c;因为我们只保留小数点后 5 位数字。 输…...

智能仓储的未来:自动化、AI与数据分析如何重塑物流中心

当仓库学会“思考”&#xff0c;物流的终极形态正在诞生 想象这样的场景&#xff1a; 凌晨3点&#xff0c;某物流中心灯火通明却空无一人。AGV机器人集群根据实时订单动态规划路径&#xff1b;AI视觉系统在0.1秒内扫描包裹信息&#xff1b;数字孪生平台正模拟次日峰值流量压力…...

【开发技术】.Net使用FFmpeg视频特定帧上绘制内容

目录 一、目的 二、解决方案 2.1 什么是FFmpeg 2.2 FFmpeg主要功能 2.3 使用Xabe.FFmpeg调用FFmpeg功能 2.4 使用 FFmpeg 的 drawbox 滤镜来绘制 ROI 三、总结 一、目的 当前市场上有很多目标检测智能识别的相关算法&#xff0c;当前调用一个医疗行业的AI识别算法后返回…...

Java多线程实现之Thread类深度解析

Java多线程实现之Thread类深度解析 一、多线程基础概念1.1 什么是线程1.2 多线程的优势1.3 Java多线程模型 二、Thread类的基本结构与构造函数2.1 Thread类的继承关系2.2 构造函数 三、创建和启动线程3.1 继承Thread类创建线程3.2 实现Runnable接口创建线程 四、Thread类的核心…...

Angular微前端架构:Module Federation + ngx-build-plus (Webpack)

以下是一个完整的 Angular 微前端示例&#xff0c;其中使用的是 Module Federation 和 npx-build-plus 实现了主应用&#xff08;Shell&#xff09;与子应用&#xff08;Remote&#xff09;的集成。 &#x1f6e0;️ 项目结构 angular-mf/ ├── shell-app/ # 主应用&…...