kubernetes - 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
解决方案
你的 YAML 似乎很好,我怀疑 2 秒的停机时间可能是由于 TCP 连接没有正确刷新到要替换的 pod。
您可以在容器中添加一个 prestop 挂钩,以确保在终止 pod 之前耗尽所有 TCP 连接吗?
推荐阅读
- reactjs - 如何使用 React.js 正确显示 JSON 记录的所有子值
- php - 限制没有变量的页面,仅在来自页面或站点时打开
- javascript - 如何使用 Websockets 连接到 MQTT 代理?
- java - 如何在迭代流期间使用丰富(外部)调用?
- regex - 如何使用 sed 和 Regex 在 Bash 中突出显示语法?
- reactjs - 在 React 中更改状态会导致 Azure SignalR 出现错误 429
- javascript - 反应钩子。周期性运行使用效果
- kendo-ui - 在 KendoUI Scheduler 中添加双月视图
- java - IntelliJ IDEA 2019.3.1 将 iml 文件存储在单独的文件夹中
- c# - 如何在运行时为类的新实例设置属性值