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

云计算-Kubernetes+Istio 实现金丝雀发布:流量管理、熔断、流量镜像、ingreess、污点及pv案例实战

介绍

在微服务架构中,如何安全、高效地实现服务发布与流量管理是保障业务稳定性的核心挑战。金丝雀发布(Canary Release)、灰度发布等策略通过精细化的流量控制,可有效降低新版本上线风险, Istio 作为主流的服务网格(Service Mesh)工具。

此次Istio 在 Kubernetes 集群中的实战应用展开,从基础环境准备(如系统内核升级以适配 IPVS 模块)到 Istio 的完整部署流程,再到核心功能的实践 —— 包括通过虚拟服务(VirtualService)和目标规则(DestinationRule)实现流量分配(如 10% 流量导向金丝雀版本)、配置熔断机制保护服务稳定性、利用流量镜像实现无感知测试、通过 Ingress Gateway 暴露服务并控制外部访问路径

1.金丝雀发布-安装 Istio

由于 Kubernetes 使用的 IPVS 模块需要系统内核版本支持,试使用提供的软件包(Canary_v1.0.tar.gz 在 http 服务下)将系统内核进行升级,在 Kubernetes 集群上完成 Istio 的安装,并将 default Namespace 设置自动注入。

升级内核

 设置 GRUB_DEFAULT=0,通过上面查询显示的编号为 0 的内核作为默认内核
 [root@master ~]# vi /etc/default/grub
 #GRUB_DEFAULT=0必须在GRUB_DEFAULT=saved下面,否则升级失败(可能),放在首部内核升级失败
 [root@master ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
 [root@masater ~]#tar -zxvf Canary_v1.0.tar.gz 
 [root@master]# cd kernel/
 [root@master kernel]# yum install -y kernel-lt-5.4.119-1.el7.elrepo.x86_64.rpm linux-firmware-20200421-80.git78c0348.el7_9.noarch.rpm
 #重启
 reboot
 #验证
 [root@master ~]# uname -r
 5.4.119-1.el7.elrepo.x86_64

安装Istio

 #导入镜像
 [root@masater ~]# cd images/ 
 #确保harbor启动完成
 [root@masater images]# ./image_push.sh
 导入比较慢,多等等
 #istio环境配置
 [root@master ~]# mv istio-1.9.5/ /usr/local/bin/
 [root@master ~]# cat /etc/profile
 export istio=/usr/local/bin/istio-1.9.5
 export PATH=$PATH:$istio/bin
 [root@master ~]# source /etc/profile
 -------------------------
 检查运行环境:
 [root@master istio-1.9.5]# istioctl x precheck
 #没有报错即可
 安装istio的核心组件:
 #注意修改IP(采用demo的安装方式)
 [root@master istio-1.9.5]# istioctl install -y --set profile=demo --set hub=192.168.30.10/library
 查看安装的资源:
 [root@master istio-1.9.5]# kubectl -n istio-system get pods
 NAME                             READY    STATUS    RESTARTS   AGE
 istio-egressgateway-6f9f4ddc9c-rgtcl     1/1        Running     0          6m46s
 istio-ingressgateway-78b47bc88b-52fd2    1/1        Running     0          6m46s
 istiod-67dbfcd4dd-56n66                  1/1        Running     0          9m10s #将default Namespace设置自动注入(为资源设置标签)
 [root@master istio-1.9.5]# kubectl label namespace default istio-injection=enabled
 namespace/default labeled
 #查看目前开启自动注入的 Namespace:
 [root@master istio-1.9.5]# kubectl get ns --show-labels=true

2.金丝雀发布-流量控制

使用文件(istio-1.9.5/samples/helloworld/helloworld.yaml)在 default 命名空间下完成 hellworld 服务的部署,然后设置路由规则来控制流量分配,创建一个虚拟服务helloworld;再创建一个目标规则 helloworld,将 10%的流量发送到金丝雀版本(v2)。

 ​
 ​
 [root@master ~]# cd /usr/local/bin/istio-1.9.5/samples/
 [root@master samples]# kubectl apply -f helloworld/helloworld.yaml
 [root@master helloworld]# cat helloworld-route.yaml 
 #创建一个虚拟服务helloworld
 apiVersion: networking.istio.io/v1alpha3
 kind: VirtualService     #针对指定服务的流量路由规则
 metadata:
   name: helloworld
 spec:
   hosts:        #必要字段:流量的目标主机
   - helloworld
   http:              #HTTP 流量规则的有序列表
 
http://www.dtcms.com/a/334578.html

相关文章:

  • 如何防止 RabbitMQ 的消息丢失?如何保证消息的可靠传输?
  • Python 项目高频设计模式实战指南:从理念到落地的全景剖析
  • Linux软件编程--线程
  • 蓝牙音频ANC四通道测试解决方案
  • 新经济形态下人才能力结构变革与发展研究报告
  • Win10快速安装.NET3.5
  • RecSys:多目标模型和MMOE
  • .NET8下的Garnet使用
  • androidstudio内存大小配置
  • 研究生第十六周周报
  • 718SJBH公交查询系统
  • 4.6 Vue 3 中的模板引用 (Template Refs)
  • Sklearn 机器学习 邮件文本分类 加载邮件数据
  • [Responsive theme color] 动态主题 | 色彩工具函数 | HEX与RGB
  • 嵌入式第三十天(线程)
  • 围棋对战游戏开发详解 附源码
  • 【C++】标准库中用于组合多个值的数据结构pair、tuple、array...
  • k8s+kubeedge的混合框架下,云端pod与边缘端pod如何进行通信?
  • HTTP协议-1-认识各个HTTP协议版本的主要特点
  • Python进行点云公共区域的提取
  • Docker目录的迁移
  • 银行间交易IMIX协议加密相关
  • 后台管理系统-4-vue3之pinia实现导航栏按钮控制左侧菜单栏的伸缩
  • 机器学习——线性回归
  • 平滑方法(smoothing)
  • Python-深度学习——pytorch的安装
  • 开源 Arkts 鸿蒙应用 开发(十八)通讯--Ble低功耗蓝牙服务器
  • VSCode匹配删除多行注释
  • JavaScript 核心语法与实战笔记:从基础到面试高频题
  • 从“Hello World”到“高并发中间件”:Go 语言 2025 系统学习路线图