【问题标题】:How to wait X second to finish rolling update in k8s?如何在 k8s 中等待 X 秒完成滚动更新?
【发布时间】:2020-10-19 20:20:31
【问题描述】:

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

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

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

我该怎么做?

【问题讨论】:

标签: kubernetes rolling-updates


【解决方案1】:

在 pod 规范中将 readiness probe and startup probe 配置为足够长的 failureThreshold * periodSeconds 以涵盖最坏情况的启动时间。例如。

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

【讨论】:

  • 好的。所以/healthz 是我的应用程序的某个端点,当响应代码为 200 时,它每 10 秒调用一次(它将在 30 秒内失败)它的 k8s 信号表明我的应用程序已准备好?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-01-12
  • 2022-12-31
  • 1970-01-01
  • 1970-01-01
  • 2015-04-11
  • 1970-01-01
  • 2017-05-08
相关资源
最近更新 更多