金丝雀发布
在有限的时间内将变更部署到服务的一部分并评估结果的渐进式发布方式。
结构与工作原理
按步骤查看箭头所示的流程。
先用少量流量验证新版本,再分阶段扩大流量。
预期收益
提升应用可靠性并降低部署风险。
权衡
在流量高峰期回滚时,稳定版 ReplicaSet 扩容期间可能出现短暂的服务降级。
对于小修复、可观测性不足或回滚路径复杂或不安全的情形,不宜采用或应谨慎使用。
运维与应用指南
综合说明,与有原文摘录支持的条目分开。实际应用前请先验证。
何时使用
先用少量真实流量验证对关键用户流程、支付或变现有重大影响的变更,也可验证有状态服务、外部集成及模式或协议变更。
应用场景
某电商平台月活用户 1,000 万,需要替换订单和支付 API。将 1% 的流量发送至金丝雀 Pod,观察错误率、延迟和支付失败率。保持 SLO 时,按 5% → 25% → 100% 逐步扩大。出现异常时立刻将金丝雀流量降为 0,切回稳定版,且回滚期间始终保留足够的稳定版容量。
部署原则
- 稳定版与金丝雀版工作负载并行部署,用 track/version 标签区分
- 用负载均衡器、Ingress 或服务网格的权重将小部分流量导向金丝雀版
- 金丝雀期间保留足量的稳定版 ReplicaSet 或 Pod,便于回滚时立即切回流量
- 保持模式、缓存和配置与旧版本兼容,确保可回滚
- 两个版本采用相同的观测代理和验证工具。
本地部署
在本地环境中通过负载均衡器或 Ingress 权重与分离的服务器池控制金丝雀比例。保留足够稳定版容量,验证少量流量后再扩大。没有云托管路由时,提前自动化监控、部署验证和回滚流程。
云环境
使用托管 Kubernetes、负载均衡器、流量管理器或服务网格,将流量权重按 1% → 5% → 25% → 100% 逐步提高。借助自动扩缩容与集中观测评估金丝雀状态。发生故障时降低权重、缩容金丝雀或重新路由至旧版本。
Kubernetes
通过稳定版和金丝雀版 Deployment、track/version 标签、Service 选择器以及 Ingress 或服务网格权重隔离流量。配置 readiness/liveness、HPA 及 Prometheus、日志和追踪,监控错误率与延迟。在将金丝雀升级或缩至 0 时,保持稳定版 ReplicaSet 的完整容量。
故障应对
常见事件包括金丝雀错误率或延迟飙升、支付失败、健康告警、模式或缓存不兼容,以及回滚时稳定版容量不足。一旦告警或验证失败,立即暂停发布,将金丝雀权重降为 0 或缩容其 ReplicaSet,让流量返回稳定版。查明原因和影响范围后决定向前修复还是回滚,确认恢复且可重新部署后进行复盘。
14 个维度的证据
反映调研时的证据收录情况,请另行判断来源是否准确、是否仍然有效。
定义与概览有证据
在有限的时间内将变更部署到服务的一部分并评估结果的渐进式发布方式。
We define canarying as a partial and time-limited deployment of a change in a service and its evaluation.解决的问题有证据
先用真实生产流量验证新版本,降低全量发布前的风险。
Test the new version with real production traffic关键组件与资源有证据
稳定版与金丝雀版并行运行,通过 track 标签等区分并分配流量。
The stable release uses `track: stable`, and the canary release uses `track: canary`.数据与资产放置原则有证据
整个金丝雀期间保留稳定版 ReplicaSet 的容量,将一部分流量单独分配给新版。
keep the stable ReplicaSet at full size for the whole canary代表性使用场景有证据
适用于支付或其他关键用户流程、有状态服务、高风险外部集成,以及重大模式或协议变更。
Changes that impact critical user flows or monetization.应用场景示例有证据
例如,分阶段在 Kubernetes 发布无状态 API 时,通过金丝雀选择器分配 20% 的流量。
# Phase 1: Stateless services (20% traffic) kubectl patch service api-service -p '{"spec":{"selector":{"version":"canary"}}}'不适用情形与注意事项有证据
对于小修复、可观测性不足或回滚路径复杂或不安全的情形,不宜采用或应谨慎使用。
When NOT to use / overuse: - For trivial fixes that increase release friction. - When observability is insufficient to detect failures.本地部署:开发、发布与运维有证据
客户的本地数据中心也可以用 Kubernetes 部署和运行服务。
our newest service offering: Bitmovin Managed On-Premise encoding云环境:开发、发布与运维有证据
在云中与现有生产版本并行部署而不中断服务,并控制流量比例。
Canary release : Deploys a new release in parallel with the original production environment (similar to Blue-Green), with no downtime.Kubernetes:开发、发布与运维有证据
在 Kubernetes 中,将金丝雀版与稳定版并行部署,对比后决定是提升还是拒绝金丝雀版。
A canary deployment strategy deploys new versions of an application next to stable, production versions.故障应对有证据
如果影响用户的健康指标触发告警,立即停止发布并调查原因。
the rollout should immediately halt and an investigation into the cause of the alert should be performed优势有证据
提升应用可靠性并降低部署风险。
Blue/green, canary, and rolling deployments all improve application reliability and reduce risk.不足与权衡有证据
在流量高峰期回滚时,稳定版 ReplicaSet 扩容期间可能出现短暂的服务降级。
Possible brown-out as the stable RS scales.代表性技术与工具有证据
Spinnaker 可轮询部署验证 API,依据阈值判断金丝雀状态。
one Spinnaker node on the stack that actually queries this API and polls it for duration更多参考资料 (21)
- Google SRE - Canary Release: Deployment Safety and Efficiency ↗
- Deploy a Release Using a Canary Deployment | Kubernetes ↗
- Implement zero-downtime deployments with blue/green, canary, and rolling strategies | Well-Architected Framework | HashiCorp Developer ↗
- Use a canary deployment strategy | Cloud Deploy | Google Cloud Documentation ↗
- Untitled result ↗
- What is Canary Deployment? When and How To Use It Effectively ↗
- What is Canary deployment? Meaning, Architecture, Examples, Use Cases, and How to Measure It (2026 Guide) - CLoudOps Now! ↗
- Canary Deployments: Pros, Cons, And 5 Critical Best Practices ↗
- How Bitmovin is Doing Multi-Stage Canary Deployments with Kubernetes in the Cloud and On-Prem | Kubernetes ↗
- Use a canary deployment strategy for Kubernetes - Azure Pipelines | Microsoft Learn ↗
- Deploy an app on Kubernetes ↗
- Azure Kubernetes Service (AKS) production upgrade strategies - Azure Kubernetes Service | Microsoft Learn ↗
- Zero-Downtime Migration to Azure Kubernetes Service (AKS) - Azure Kubernetes Service | Microsoft Learn ↗
- Serverless operations | CNCF ↗
- Architecture strategies for safe deployment practices - Microsoft Azure Well-Architected Framework | Microsoft Learn ↗
- 15.07 — Rollback playbook - The Bookstore Guide — Kubernetes from Zero to Production ↗
- Recommendations for designing a deployment failure mitigation strategy - Power Platform | Microsoft Learn ↗
- Deployment Rollback Runbook | Doc | StackPractices ↗
- Rollback | MinimumCD Practice Guide ↗
- Rollback Made It Worse: 5-Layer CI/CD Auto-Rollback Architecture and 4 Production Pitfalls | SRE Engineering Practice ↗
- Prod Lessons - Deployment Validation and Graceful Degradation - InfoQ ↗