创建Deployment
nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
progressDeadlineSeconds: 600
replicas: 10
revisionHistoryLimit: 10
selector:
matchLabels:
app: nginx-deployment
strategy:
rollingUpdate:
# 升级过程中最多比replicas多出的新增Pod数量
maxSurge: 25%
# 升级过程中最多的无法提供服务的Pod数量
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: nginx-deployment
spec:
containers:
- name: nginx-deployment
image: nginx:1.9
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
创建应用
kubectl create -f nginx-deployment.yaml
更新镜像
kubectl set image nginx-deployment nginx-deployment=nginx:1.9.3
滚动更新过程
创建newRS,replicas 是3。
// 10*25%=2.5
// 向上取整为3
maxSurge = replicas * deployment.spec.strategy.rollingUpdate.maxSurge
缩容oldRS,replicas是8。
// 10*0.25=2.5
// 向下取整为2
maxUnavailable = replicas * deployment.spec.strategy.rollingUpdate.maxUnavailable
newRS不断增加到10个,oldRS不断减少到0个。变化过程中,Pod总数控制在13个,最少的可提供服务数量控制在8个。
// 8 = 10 - 2
minAvailable := *(deployment.Spec.Replicas) - maxUnavailable
标签:10,滚动,replicas,Deployment,更新,nginx,maxUnavailable,deployment From: https://www.cnblogs.com/WJQ2017/p/17093379.html