Rolling 更新
一句话解释
rolling 更新 gradually replaces 旧实例使用新 ones, ensuring 零 downtime 期间部署.
用大白话说
A rolling update is a deployment strategy that updates your application gradually, one instance at a time, so there is always at least one healthy instance serving traffic. This means zero downtime during deployment.
例如, if you have 4 replicas and you update the image: Kubernetes creates 1 new Pod with the new version, waits for it to be ready, then removes 1 old Pod. It repeats this until all 4 Pods are running the new version.
你可以control the speed: maxSurge (how many new Pods can be created above the desired count) and maxUnavailable (how many Pods can be unavailable during the update). If something goes wrong, you can roll back to the previous version.
This is the default strategy in Kubernetes Deployments.
示例
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # create at most 1 extra Pod
maxUnavailable: 0 # never reduce capacity
# ...
# Update: kubectl set image deployment/app app=app:v2这个 RollingUpdate 策略创建 at 大多数 1 extra Pod at 时间 and 从不 reduces available capacity below desired 数量.
工作原理
- You update the container image in the Deployment.
- Kubernetes creates a new Pod with the new image.
- Once the new Pod is ready, an old Pod is removed.
- This repeats until all Pods are running the new version.
常见混淆
容易混淆的对象: Blue-Green 部署
关键区别: rolling 更新 gradually replaces 实例 (mixed 旧/新期间更新); blue-green 切换所有 traffic at 一次从 旧到 新 (否 mixing, 但需要双 capacity).
相关术语
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。