kubernetes-guide/codeblock/graceful/update-strategy.yaml

39 lines
1.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 探测
periodSeconds: 5
readinessProbe:
httpGet:
path: /
port: 80
# highlight-next-line
successThreshold: 1 # 运行过程中探测 1 次成功就认为 ready可在抖动导致异常后快速恢复服务
periodSeconds: 5