渐进式交付实践:通过 Argo Rollouts 和 FSM Gateway 实现金丝雀发布

渐进式交付(Progressive delivery)是一种软件发布策略,旨在更安全、更可控地将新版本软件逐步推出给用户。它是持续交付的进一步提升,允许开发团队在发布新版本时拥有更细粒度的控制,例如可以根据用户反馈、性能指标和其他关键数据来调整发布过程。渐进式交付通过利用一系列现代部署方案如蓝绿部署(Blue-Green Deployments)、金丝雀发布(Canary Releases)等让开发团队能够更灵活地管理风险,同时加快新功能的发布速度。

Argo Rollouts 包括一个 Kubernetes控制器 和一组 CRD,提供如蓝绿色、金丝雀、金丝雀分析、体验等高级部署功能和 Kubernetes 的渐进交付功能。

之前曾分享过 使用 Argo Rollouts 和服务网格实现自动可控的金丝雀发布(彼时的服务网格现已更名为 FSM),这是通过服务网格技术实现了东西向流量的金丝雀发布。虽然以此可以确保内部服务之间的平滑过渡,但这并不足以保证最终用户体验的质量。我们还需要手段来控制新版本对最终用户的可变性及影响,因此对于南北向流量 – 入口的网络流量 – 金丝雀发布变得不可或缺。

对于 Kubernetes 的入口流量管理,常见的有如 Ingress Controller、Gateway API。作为服务网格 FSM 组件之一的 FSM Gateway 是一个开源的 Kubernetes Gateway API 实现,它使用可编程应用引擎 Pipy 作为代理配置路由和策略来管理入口流量。关于 FSM Gateway 的使用,可以查看之前的 系列文章。

rollouts-plugin-trafficrouter-gatewayapi 是 Argo Rollouts 的一个插件它实现了 Kubernetes Gateway API 规范。使用它可以使用 FSM Gateway 实现渐进式的交付,当然你可以使用其他的实现。

今天就以 FSM Gateway 为例介绍如何使用 Argo Rollouts 进行南北向流量的金丝雀发布。

前置条件

  • Kubernetes 集群,最低版本 1.23
  • kubectl cli

准备环境

安装 FSM Gateway

我们可以通过 FSM CLI 来安装 FSM Gateway,参考 文档 下载并安装 FSM CLI,当前最新的版本为 1.2.3。

system=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m | sed -E 's/x86_/amd/' | sed -E 's/aarch/arm/')
release=v1.2.3
curl -L https://github.com/flomesh-io/fsm/releases/download/$release/fsm-$release-$system-$arch.tar.gz | tar -vxzf -
./$system-$arch/fsm version
cp ./$system-$arch/fsm /usr/local/bin/fsm

使用下面的命令安装 FSM Gateway,作为 服务网格 FSM 的众多组件之一,FSM Gateway 的运行会由 FSM 控制器管理。

fsm install \--set=fsm.fsmGateway.enabled=true

如果你已经安装了 FSM,可以通过下面的命令来启用网关。

fsm gateway enable

在成功安装 FSM Gateway 之后,可以看到 gateway class fsm-gatweay-cls 已经就绪。

kubectl get gatewayclass
NAME              CONTROLLER                      ACCEPTED   AGE
fsm-gateway-cls   flomesh.io/gateway-controller   True       2m35s

与 FSM Gateway 一同安装的还有 Gateway API 的 CRD。

创建 Gateway 对象

安装了 FSM Gateway 并不意味着马上可以开始接管流量,我们还需要创建 Gateway 对象。

kubectl apply -n default -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:name: simple-fsm-gateway
spec:gatewayClassName: fsm-gateway-clslisteners:- protocol: HTTPport: 80name: httpallowedRoutes:namespaces:from: Same
EOF

获取 Gateway 的 IP 地址。

export GATEWAY_IP=$(kubectl get svc -n default -l app=fsm-gateway -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}')

安装 Argo Rollouts

使用下面的命令在集群中安装最新的 Argo Rollouts,其运行在命名空间 argo-rollouts 中。

kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml

为了 Argo Rollouts 能够通过修改路由来控制流量,需要为其创建 ClusterRoleClusterRoleBinding。(这个操作在每个集群只需一次即可)

kubectl apply -f - <<EOF
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:name: gateway-controller-rolenamespace: argo-rollouts
rules:- apiGroups:- "*"resources:- "*"verbs:- "*"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:name: gateway-admin
roleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: gateway-controller-role
subjects:- namespace: argo-rolloutskind: ServiceAccountname: argo-rollouts
EOF
安装 kubectl argo 插件

使用 kubectl argo 插件可以通过命令行对发布进行操作。

在 macOS 下,其他平台参考 官方安装文档。

brew install argoproj/tap/kubectl-argo-rollouts

通过下面的命令启动 Argo Rollouts Dashboard,在浏览器中打开 [http://localhost:3100/rollouts](http://localhost:3100/rollouts) 就可访问 Dashboard。

kubectl argo rollouts dashboard

安装 Rollouts Gateway API 插件

安装 Gateway API 插件需要在 Configmap 中指定插件的下载地址,执行下面的命令后 Rollouts 的控制面会从该地址下载并安装。截止本文发布,插件的最新版本是 0.2.0。

注意,请安装对应平台的插件。

kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:name: argo-rollouts-config # must be so namenamespace: argo-rollouts # must be in this namespace
data:trafficRouterPlugins: |-- name: "argoproj-labs/gatewayAPI"location: "https://github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/releases/download/v0.2.0/gateway-api-plugin-linux-amd64"
EOF

创建 Service

创建两个 Service argo-rollouts-stable-serviceargo-rollouts-canary-service,这两个 Service 将作为 Gateway 的后端服务,由 Rollouts 控制到各个 Service 的流量权重。

kubectl apply -n default -f - <<EOF
apiVersion: v1
kind: Service
metadata:name: argo-rollouts-stable-service
spec:ports:- port: 80targetPort: httpprotocol: TCPname: httpselector:app: rollouts-demo
---
apiVersion: v1
kind: Service
metadata:name: argo-rollouts-canary-service
spec:ports:- port: 80targetPort: httpprotocol: TCPname: httpselector:app: rollouts-demo
EOF

创建 HTTP 路由

有了服务之后,就是在 Gateway 创建对应的 HTTPRoute 配置路由,默认将所有的流量都代理到稳定版。

kubectl apply -n default -f - <<EOF
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1beta1
metadata:name: argo-rollouts-http-route
spec:parentRefs:- name: simple-fsm-gatewayport: 80hostnames:- "demo.example.com"rules:- matches:- path:type: PathPrefixvalue: /  backendRefs:- name: argo-rollouts-stable-servicekind: Serviceport: 100- name: argo-rollouts-canary-servicekind: Serviceport: 0
EOF

创建 Rollout

创建资源 Rollout:

  • 使用策略 canary
  • 指定创面创建的两个 Service 分别作为 stableServicecanaryService
  • 流量路由使用插件 argoproj-labs/gatewayAPI,以及操作的 HTTPRouteargo-rollouts-http-route
  • 指定发布的流程 steps
  • 最终要的就是 template 中配置我们的应用,也就是稳定版,与 Deployment 的 template 一致。
kubectl apply -n default -f- <<EOF
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:name: rollouts-demo
spec:replicas: 3strategy:canary:canaryService: argo-rollouts-canary-service # our created canary servicestableService: argo-rollouts-stable-service # our created stable servicetrafficRouting:plugins:argoproj-labs/gatewayAPI:httpRoute: argo-rollouts-http-route # our created httproutenamespace: defaultsteps:- setWeight: 30- pause: { duration: 30s }- setWeight: 60- pause: { duration: 30s }- setWeight: 100- pause: { duration: 30s }revisionHistoryLimit: 2selector:matchLabels:app: rollouts-demotemplate:metadata:labels:app: rollouts-demospec:containers:- name: rollouts-demoimage: kostiscodefresh/summer-of-k8s-app:v1ports:- name: httpcontainerPort: 8080protocol: TCPresources:requests:memory: 32Micpu: 5m
EOF

创建完成后便通过命令行访问示例应用了。

curl -H "host: demo.example.com" $GATEWAY_IP/callme

此时会看到如下的结果,说明正在运行的 1.0 版本。

<div class='pod' style='background:#44B3C2'> ver: 1.0</div>

执行金丝雀发布

接着我们修改 Rollout,将示例应用的镜像更新为 2.0 版本。

kubectl patch rollout rollouts-demo -n default \--type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"kostiscodefresh/summer-of-k8s-app:v2"}]'

可以通过下命令持续查看示例应用的运行。

while true; do curl -H "host: demo.example.com" $GATEWAY_IP/callme; done

当然,在 Argo Rollouts 的 Dashboard 中我们可以更加直观地看到 Rollout 的执行流程。

最终,rollouts-demo 完成升级,旧版本的实例完全退出。

关于 Flomesh

Flomesh(易衡科技)成立于 2018 年,自主研发并开源了高性能可编程代理 Pipy(https://github.com/flomesh-io/pipy)。以 Pipy 为基础,Flomesh 研发了软件负载均衡、服务网格两款软件产品。为工信部认证的可信云产品、可信开源项目。

Flomesh 核心竞争力来自完全自研的核心组件 Pipy,该组件高性能、高可靠、低延迟、可编程、可扩展、低依赖,采用 C++ 开发,内置自研的 JS 引擎,支持适用 JS 脚本做扩展开发。支持包括 x86、arm、龙芯、海光等硬件 CPU 架构;支持 Linux、FreeBSD、macOS、Windows、OpenWrt 等多种核心的操作系统。

Flomesh 成立以来,以技术为根基、以客户为导向,产品被应用在头部股份制商业银行总行、大型保险公司、运营商总部以及研究院等众多客户和多个场景。

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/400.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Docker】安装Redis、Nginx、MongoDb、Jenkins

1、安装redis mkdir -p /docker/redis mkdir -p /docker/redis/data touch /docker/redis/redis.conf touch /docker/redis/redis.bash编辑配置文件 vim /docker/redis/redis.conf # Redis配置文件# Redis默认不是以守护进程的方式运行&#xff0c;可以通过该配置项修改&…

css八股

伪类&#xff0c;伪元素 伪类&#xff1a; 1.指某种特定的行为或者状态&#xff0c;例如鼠标悬停&#xff0c;点击&#xff0c;第一个子元素等 2.以&#xff1a;开头&#xff0c;&#xff1a;hover&#xff0c;&#xff1a;focus 3.伪类不会形成新的元素&#xff0c;只会改…

柱层析SOP

1.TLC检测 尝试极性PE:EA的比值由5&#xff1a;1 到1&#xff1a;1&#xff0c;如若色谱上点未发生变化&#xff0c;再继续尝试极性DCM:MeOH由5&#xff1a;1 到 1&#xff1a;1。 但需保证各点的Rf分布在0.1到0.9之间。 PE:石油醚 EA&#xff1a;乙酸乙酯 DCM&am…

【论文阅读】YOLO-World | 开集目标检测

Date&#xff1a;2024.02.22&#xff0c;Tencent AI Lab&#xff0c;华中科技大学Paper&#xff1a;https://arxiv.org/pdf/2401.17270.pdfGithub&#xff1a;https://github.com/AILab-CVC/YOLO-World 论文解决的问题&#xff1a; 通过视觉语言建模和大规模数据集上的预训练来…

ruoyi-nbcio-plus基于vue3的flowable的消息中心我的消息的升级修改

更多ruoyi-nbcio功能请看演示系统 gitee源代码地址 前后端代码&#xff1a; https://gitee.com/nbacheng/ruoyi-nbcio 演示地址&#xff1a;RuoYi-Nbcio后台管理系统 http://122.227.135.243:9666/ 更多nbcio-boot功能请看演示系统 gitee源代码地址 后端代码&#xff1a…

Python数据可视化:散点图matplotlib.pyplot.scatter()

【小白从小学Python、C、Java】 【计算机等级考试500强双证书】 【Python-数据分析】 Python数据可视化&#xff1a; 散点图 matplotlib.pyplot.scatter() 请问关于以下代码表述错误的选项是&#xff1f; import matplotlib.pyplot as plt x [1, 2, 3, 4, 5] y [2, 3, 5, 7,…

热塑性聚氨酯TPU的特性有哪些?UV胶水能够粘接热塑性聚氨酯TPU吗?又有哪些优势呢?

热塑性聚氨酯&#xff08;Thermoplastic Polyurethane&#xff0c;TPU&#xff09;是一种具有多种优异性能的弹性塑料&#xff0c;广泛用于各种应用领域。以下是TPU的一些主要特性&#xff1a; 弹性和柔软性&#xff1a; TPU具有良好的弹性和柔软性&#xff0c;能够在受力后迅速…

JVM复习总结2024.4.18(很重要)

一、 1. 基于JDK1.8的String intern()方法解析 intern方法 1.8&#xff1a; 调用字符串对象的intern方法&#xff0c;会将该字符串对象尝试放入到串池中 如果串池中没有该字符串对象&#xff0c;则放入成功如果有该字符串对象&#xff0c;则放入失败 无论放入是否成功&#xff…

数据库-Redis(18)

目录 86.Redis 分布式锁的实现?什么是RedLock? 87.Redis缓存有哪些问题,如何解决? 88.Redis性能问题有哪些,如何分析定位解决?

短视频批量采集提取软件|视频下载工具

短视频批量采集提取软件&#xff1a;高效获取视频资源 一、开发背景 在日常业务中&#xff0c;我们经常需要获取大量的短视频资源&#xff0c;以支持各种需求&#xff0c;但传统的获取方式过于繁琐&#xff0c;一一复制链接下载效率低下。基于此需求&#xff0c;我们开发了一…

Jenkins机器已经安装了ansible, 运行的时候却报错ansible: command not found

操作系统&#xff1a;MacOS Jenkins log提示 ansible: command not found 直接在Jenkins 机器中&#xff0c;进入一样的目录执行ansible --version OK 原因&#xff1a; Jenkins 默认使用的环境是 /usr/bin, 而我的ansible 安装配置在conda3 下面&#xff0c;所以需要在Jenkin…

【工位ubuntu的配置】补充

软件 安装桌面图标的问题 登录密码 root的密码为&#xff1a;19980719 按照如下的链接进行配置&#xff1a; https://blog.csdn.net/zhangmingfie/article/details/131102331?spm1001.2101.3001.6650.3&utm_mediumdistribute.pc_relevant.none-task-blog-2%7Edefault%7E…

Meta发布新AI模型Llama 3,包含80亿和700亿参数

据Odaily星球日报报道&#xff0c;Meta旗下AIatMeta官方在X平台发文&#xff0c;Meta正式发布了包括80亿参数和700亿参数在内的2个新AI模型Llama 3。这些模型实现了新功能&#xff0c;如改进的推理能力&#xff0c;并为特定模型设定了新的最先进水平。在未来几个月&#xff0c;…

opencv图像转QPixmap格式图像后无彩色且中间有一条黑线

背景 自己使用PyQt5开发了一个界面&#xff0c;需要在界面的某个标签上显示opencv-python处理后的图像&#xff0c; 原来使用的代码段如下&#xff1a; img_rgb cv2.cvtColor(cvimage, cv2.COLOR_BGR2RGB)cv2.imwrite(2.jpg,img_rgb)qimg QImage(img_rgb.data, img_rgb.shape…

工业控制(ICS)---modbus

Modbus Modbus&#xff0c;市场占有率高、出题频率高,算是最常见的题目&#xff0c;因为这个协议也是工控领域最常见的协议之一&#xff0c;主要有三类 Modbus/RTU 从机地址1B功能码1B数据字段xBCRC值2B 最大长度256B&#xff0c;所以数据字段最大长度252B Modbus/ASCII …

DFS之剪枝2

给定两个整数 n , x n,x n,x。 你可以对 x x x 进行任意次以下操作&#xff1a; 选择 x x x 的一位数字 y y y&#xff0c;将 x x x 替换为 x y x \times y xy。 请你计算通过使用上述操作&#xff0c;将 x x x 变为一个 n n n 位数字&#xff08;不含前导 0 0 0&…

C++笔记:引用

目录 概念&#xff1a; ​编辑 引用的特性&#xff1a; 引用中的权限问题&#xff1a; 引用与指针的区别&#xff1a; 引用的使用&#xff1a; 概念&#xff1a; 引用是给已存在变量取一个别名&#xff0c;编译器不会为引用变量开辟内存空间。 引用的符号&#xff1a;&…

NLP(3)--利用nn反向计算参数

前言 仅记录学习过程&#xff0c;有问题欢迎讨论 获取数据 自定义一个方程&#xff0c;获取一批数据X,Y import matplotlib.pyplot as pyplot import math import sysX [0.01 * x for x in range(100)] Y [2*x**2 3*x 4 for x in X] print(X) print(Y) pyplot.scatter(…

KV Cache 技术分析

原文&#xff1a;Notion – The all-in-one workspace for your notes, tasks, wikis, and databases. 1 什么是KV Cache LLM&#xff08;大型语言模型&#xff09;中的 Attention 机制中的 KV Cache&#xff08;键值缓存&#xff09;主要作用是存储键值对&#xff0c;以避免在…

ChatGPT又多了一个强有力的竞争对手:Meta发布Llama 3开源模型!附体验地址

大家好&#xff0c;我是木易&#xff0c;一个持续关注AI领域的互联网技术产品经理&#xff0c;国内Top2本科&#xff0c;美国Top10 CS研究生&#xff0c;MBA。我坚信AI是普通人变强的“外挂”&#xff0c;所以创建了“AI信息Gap”这个公众号&#xff0c;专注于分享AI全维度知识…