当前位置: 首页 > 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…...

Linux应用开发之网络套接字编程(实例篇)

服务端与客户端单连接 服务端代码 #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <pthread.h> …...

大数据学习栈记——Neo4j的安装与使用

本文介绍图数据库Neofj的安装与使用&#xff0c;操作系统&#xff1a;Ubuntu24.04&#xff0c;Neofj版本&#xff1a;2025.04.0。 Apt安装 Neofj可以进行官网安装&#xff1a;Neo4j Deployment Center - Graph Database & Analytics 我这里安装是添加软件源的方法 最新版…...

(十)学生端搭建

本次旨在将之前的已完成的部分功能进行拼装到学生端&#xff0c;同时完善学生端的构建。本次工作主要包括&#xff1a; 1.学生端整体界面布局 2.模拟考场与部分个人画像流程的串联 3.整体学生端逻辑 一、学生端 在主界面可以选择自己的用户角色 选择学生则进入学生登录界面…...

React Native 导航系统实战(React Navigation)

导航系统实战&#xff08;React Navigation&#xff09; React Navigation 是 React Native 应用中最常用的导航库之一&#xff0c;它提供了多种导航模式&#xff0c;如堆栈导航&#xff08;Stack Navigator&#xff09;、标签导航&#xff08;Tab Navigator&#xff09;和抽屉…...

系统设计 --- MongoDB亿级数据查询优化策略

系统设计 --- MongoDB亿级数据查询分表策略 背景Solution --- 分表 背景 使用audit log实现Audi Trail功能 Audit Trail范围: 六个月数据量: 每秒5-7条audi log&#xff0c;共计7千万 – 1亿条数据需要实现全文检索按照时间倒序因为license问题&#xff0c;不能使用ELK只能使用…...

论文浅尝 | 基于判别指令微调生成式大语言模型的知识图谱补全方法(ISWC2024)

笔记整理&#xff1a;刘治强&#xff0c;浙江大学硕士生&#xff0c;研究方向为知识图谱表示学习&#xff0c;大语言模型 论文链接&#xff1a;http://arxiv.org/abs/2407.16127 发表会议&#xff1a;ISWC 2024 1. 动机 传统的知识图谱补全&#xff08;KGC&#xff09;模型通过…...

【OSG学习笔记】Day 16: 骨骼动画与蒙皮(osgAnimation)

骨骼动画基础 骨骼动画是 3D 计算机图形中常用的技术&#xff0c;它通过以下两个主要组件实现角色动画。 骨骼系统 (Skeleton)&#xff1a;由层级结构的骨头组成&#xff0c;类似于人体骨骼蒙皮 (Mesh Skinning)&#xff1a;将模型网格顶点绑定到骨骼上&#xff0c;使骨骼移动…...

Web 架构之 CDN 加速原理与落地实践

文章目录 一、思维导图二、正文内容&#xff08;一&#xff09;CDN 基础概念1. 定义2. 组成部分 &#xff08;二&#xff09;CDN 加速原理1. 请求路由2. 内容缓存3. 内容更新 &#xff08;三&#xff09;CDN 落地实践1. 选择 CDN 服务商2. 配置 CDN3. 集成到 Web 架构 &#xf…...

Typeerror: cannot read properties of undefined (reading ‘XXX‘)

最近需要在离线机器上运行软件&#xff0c;所以得把软件用docker打包起来&#xff0c;大部分功能都没问题&#xff0c;出了一个奇怪的事情。同样的代码&#xff0c;在本机上用vscode可以运行起来&#xff0c;但是打包之后在docker里出现了问题。使用的是dialog组件&#xff0c;…...

Mobile ALOHA全身模仿学习

一、题目 Mobile ALOHA&#xff1a;通过低成本全身远程操作学习双手移动操作 传统模仿学习&#xff08;Imitation Learning&#xff09;缺点&#xff1a;聚焦与桌面操作&#xff0c;缺乏通用任务所需的移动性和灵活性 本论文优点&#xff1a;&#xff08;1&#xff09;在ALOHA…...