渐进式交付实践:通过 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,一经查实,立即删除!

相关文章

【论文阅读】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;能够在受力后迅速…

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

短视频批量采集提取软件&#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…

工业控制(ICS)---modbus

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

C++笔记:引用

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

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全维度知识…

力扣:两数之和

知识点&#xff1a; 动态数组的创建&#xff1a; #include<stdlib.h> arr (int*)malloc(len * sizeof(int)); 如何使用sacnf输入数组&#xff1a; scanf 函数在读取输入时&#xff0c;会自动跳过空格&#xff08;空格、制表符、换行符等&#xff09;和换行符&#…

vscode绿绿主题setting config

下载插件Green Tree Theme 选greentree ctrl shift p找到setting {"workbench.colorTheme": "Green Tree","editor.fontSize": 16.5, // 字号"workbench.colorCustomizations": {"[Green Tree]": {"activityBarBadge.…

算法一:数字 - 两数之和

给定一个整数数组 nums 和一个目标值 target&#xff0c;请你在该数组中找出和为目标值的那 两个 整数&#xff0c;并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是&#xff0c;数组中同一个元素不能使用两遍。 来源&#xff1a;力扣(LeetCode) 链接&#xf…

scala---基础核心知识(变量定义,数据类型,流程控制,方法定义,函数定义)

一、什么是scala Scala 是一种多范式的编程语言&#xff0c;其设计初衷是要集成面向对象编程和函数式编程的各种特性。Scala运行于Java平台&#xff08;Java虚拟机&#xff09;&#xff0c;并兼容现有的Java程序。 二、为什么要学习scala 1、优雅 2、速度快 3、能融合到hado…

管道流设计模式结合业务

文章目录 流程图代码实现pomcontextEventContextBizTypeAbstractEventContext filterEventFilterAbstractEventFilterEventFilterChainFilterChainPipelineDefaultEventFilterChain selectorFilterSelectorDefaultFilterSelector 调用代码PipelineApplicationcontrollerentitys…

浅析binance新币OMNI的前世今生

大盘跌跌不休&#xff0c;近期唯一的指望就是binance即将上线的OMNI 。虽然目前查到的空投数量不及预期&#xff0c;但OMNI能首发币安&#xff0c;确实远超预期了。 OMNI代币总量1亿&#xff0c;初始流通仅10,391,492枚&#xff0c;其中币安Lanchpool可挖350万枚 对于OMNI这个…

设计模式——模版模式21

模板方法模式在超类中定义了一个事务流程的框架&#xff0c; 允许子类在不修改结构的情况下重写其中一个或者多个特定步骤。下面以ggbond的校招礼盒发放为例。 设计模式&#xff0c;一定要敲代码理解 模版抽象 /*** author ggbond* date 2024年04月18日 17:32* 发送奖品*/ p…

50.HarmonyOS鸿蒙系统 App(ArkUI)web组件实现简易浏览器

50.HarmonyOS鸿蒙系统 App(ArkUI)web组件实现简易浏览器 配置网络访问权限&#xff1a; 跳转任务&#xff1a; Button(转到).onClick(() > {try {// 点击按钮时&#xff0c;通过loadUrl&#xff0c;跳转到www.example1.comthis.webviewController.loadUrl(this.get_url);} …

代码随想录第39天|62.不同路径 63. 不同路径 II

62.不同路径 62. 不同路径 - 力扣&#xff08;LeetCode&#xff09; 代码随想录 (programmercarl.com) 动态规划中如何初始化很重要&#xff01;| LeetCode&#xff1a;62.不同路径_哔哩哔哩_bilibili 一个机器人位于一个 m x n 网格的左上角 &#xff08;起始点在下图中标…