update at 2024-04-19 15:45:54
parent
0eedaca203
commit
932fb96179
|
@ -0,0 +1,36 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
strategy:
|
||||
# highlight-start
|
||||
type: RollingUpdate
|
||||
rollingUpdate: # 单个串行升级,等新副本 ready 后才开始销毁旧副本
|
||||
maxUnavailable: 0
|
||||
maxSurge: 1
|
||||
# highlight-end
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx:latest
|
||||
startupProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 80
|
||||
# highlight-next-line
|
||||
successThreshold: 5 # 新副本启动时,连续探测成功多次后才交给 readinessProbe 探测
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 80
|
||||
# highlight-next-line
|
||||
successThreshold: 1 # 运行过程中探测 1 次成功就认为 ready,可在抖动导致异常后快速恢复服务
|
|
@ -0,0 +1,12 @@
|
|||
# 配置保守的更新策略
|
||||
|
||||
## 保守更新策略
|
||||
|
||||
如果对稳定性要求较高,可以设置比较保守的滚动更新策略:
|
||||
1. 避免在滚动时可以正常处理请求的 Pod 数量减少导致部分请求因后端 Pod 处理不过来而异常。
|
||||
2. 减缓发版速度,避免新版应用引入难以发现的问题快速扩散,方便发现后及时回滚恢复。
|
||||
3. 新副本启动时,多给应用一些时间进行准备,避免某些应用虽然探测接口返回就绪,但实际处理能力还没跟上,过早转发请求过来可能导致异常。
|
||||
|
||||
## 配置示例
|
||||
|
||||
<FileBlock file="graceful/update-strategy.yaml" showLineNumbers />
|
|
@ -18,6 +18,7 @@ const sidebars: SidebarsConfig = {
|
|||
'graceful-shutdown/why-cannot-receive-sigterm',
|
||||
'graceful-shutdown/propagating-signals-in-shell',
|
||||
'graceful-shutdown/use-prestop',
|
||||
'graceful-shutdown/update-strategy',
|
||||
'graceful-shutdown/persistent-connection',
|
||||
'graceful-shutdown/lb-to-pod-directly',
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue