Kubernetes滚动更新介绍及使用-minReadySeconds
滚动升级Deployment
现在我们将刚刚保存的yaml文件中的nginx镜像修改为 nginx:1.13.3,然后在spec下面添加滚动升级策略:
| 1 2 3 4 5 6 7 | minReadySeconds: 5 strategy:   # indicate which strategy we want for rolling update   type: RollingUpdate   rollingUpdate:     maxSurge: 1     maxUnavailable: 1 | 
- minReadySeconds:
- Kubernetes在等待设置的时间后才进行升级
- 如果没有设置该值,Kubernetes会假设该容器启动起来后就提供服务了
- 如果没有设置该值,在某些极端情况下可能会造成服务服务正常运行
 
- maxSurge:
- 升级过程中最多可以比原先设置多出的POD数量
- 例如:maxSurage=1,replicas=5,则表示Kubernetes会先启动1一个新的Pod后才删掉一个旧的POD,整个升级过程中最多会有5 1个POD。
 
- maxUnavaible:
- 升级过程中最多有多少个POD处于无法提供服务的状态
- 当 maxSurge不为0时,该值也不能为0
- 例如:maxUnavaible=1,则表示Kubernetes整个升级过程中最多会有1个POD处于无法服务的状态。
 
然后执行命令:
| 1 2 | $ kubectl apply -f nginx-deployment.yaml deployment "nginx-deploy" configured | 
实例操作:
spec:
  minReadySeconds: 120
  progressDeadlineSeconds: 600
  replicas: 2
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: image-train-prod-k8s
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
.spec.minReadySecondsis an optional field that specifies the minimum number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available. This defaults to 0 (the Pod will be considered available as soon as it is ready). To learn more about when a Pod is considered ready, see Container Probes
So your newly created app pod have to be ready for .spec.minReadySeconds seconds to be considered as available.
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号