如何等待 X 秒完成 k8s 中的滚动更新?

How to wait X second to finish rolling update in k8s?

我正在使用 k8s 部署我的 docker 应用程序。

一旦声明应用需要 20-30 秒才能准备就绪,应用很大,启动时需要一些时间。

开机平均时间为20-30秒。我想在滚动更新期间等待 60 秒。因为现在,旧 pod 在启动新应用程序时终止(在新 pod 中)。

我该怎么做?

在 pod 规范中配置 readiness probe and startup probe failureThreshold * periodSeconds 足够长以涵盖最坏情况下的启动 time.As 示例。

ports:
- name: readiness-port
  containerPort: 8080
  hostPort: 8080

readinessProbe:
  httpGet:
    path: /healthz
    port: readiness-port
  failureThreshold: 1
  periodSeconds: 10

startupProbe:
  httpGet:
    path: /healthz
    port: readiness-port
  failureThreshold: 30
  periodSeconds: 10