您当前的位置: 首页 >> 豫闻天下 > >> 内容页

每日资讯:Deployment滚动更新策略Recreate

2023-04-30 11:17:42 来源:腾讯云


【资料图】

Recreate策略

Recreate策略是另一种滚动更新策略,它会先删除旧的Pod,然后再创建新的Pod。在进行滚动更新时,所有的Pod都会被同时停止,然后全部替换为新的Pod。Recreate策略的优点是可以避免新旧Pod的共存问题,但会在升级期间中断服务。

下面是一个Recreate策略的示例:

apiVersion: apps/v1kind: Deploymentmetadata:  name: nginx-deployment  labels:    app: nginxspec:  replicas: 4  selector:    matchLabels:      app: nginx  template:    metadata:      labels:        app: nginx    spec:      containers:        - name: nginx          image: nginx:1.16          ports:            - containerPort: 80          livenessProbe:            httpGet:              path: /              port: 80            initialDelaySeconds: 10            periodSeconds: 5            timeoutSeconds: 2            failureThreshold: 3          readinessProbe:            httpGet:              path: /              port: 80            initialDelaySeconds: 10            periodSeconds: 5            timeoutSeconds: 2            failureThreshold: 3          lifecycle:            preStop:              exec:                command: ["/usr/sbin/nginx","-s","quit"]

这是一个创建了4个nginx Pod的Deployment对象,每个Pod中的nginx容器都有一个存活性探针和就绪性探针,并且在终止Pod之前执行preStop钩子,使用/usr/sbin/nginx -s quit命令关闭nginx服务器。这确保了nginx在关闭之前可以正常完成当前正在处理的请求。

关键词:
分享到:
x 广告
x 广告

  Copyright @ 2001-2013 www.9774.com.cn All Rights Reserved 中国时尚网 版权所有

联系方式:954 29 18 82 @qq.com

   粤ICP备18025786号  营业执照公示信息   未经吉中国时尚网书面授权,请勿建立镜像,转载请注明来源,违者依法必究

关于我们 | 联系方式 | 版权声明 | 招聘信息 | 友情链接 | 合作伙伴 |