首页 > 解决方案 > GKE RollingUpdate 停机

问题描述

我正在尝试对部署进行滚动更新,但我仍然需要大约 2 秒的停机时间。我是否错误配置了我的 yaml?我还使用大使作为 API 网关,不完全确定问题出在 API 网关还是部署中。

我编写了一个简单的 shell 脚本,它每秒运行一次 curl,使用此配置我总是有大约 2 秒的停机时间。任何帮助深表感谢。

这是我的相关配置。

部署方法:

kubectl apply -f MY_DEPLOYMENT.yaml

部署片段:

apiVersion: apps/v1 
kind: Deployment
metadata:
  name: web-service-rf
spec:
  selector:
    matchLabels:
      app: web-service-rf
  replicas: 2 # tells deployment to run 2 pods matching the template
  strategy:
    rollingUpdate:
      maxSurge: 4
      maxUnavailable: 0%

活跃度和就绪度探测:

  livenessProbe:
    httpGet:
      path: /health/liveness
      port: 80
    initialDelaySeconds: 5
    periodSeconds: 3
  readinessProbe:
    httpGet:
      path: /health/readiness
      port: 80
    initialDelaySeconds: 5
    periodSeconds: 5
    successThreshold: 1 

标签: kubernetesgoogle-kubernetes-engine

解决方案


你的 YAML 似乎很好,我怀疑 2 秒的停机时间可能是由于 TCP 连接没有正确刷新到要替换的 pod。

您可以在容器中添加一个 prestop 挂钩,以确保在终止 pod 之前耗尽所有 TCP 连接吗?


推荐阅读