首页/云/云与容器速查/三类探针:liveness/readiness/startup
Kubernetes68 条

三类探针:liveness/readiness/startup

readiness 决定是否进流量(失败摘除端点);liveness 决定是否重启(失败杀容器);startup 保护慢启动(成功前其他探针不生效)。职责不同,乱配会把稳定性越治越差。

云与容器速查云更新于 2026-10-12

探针职责

探针失败后果典型场景
readinessProbe从 Endpoints 摘除,不重启依赖未就绪临时摘流
livenessProbe重启容器死锁/卡死自动恢复
startupProbe重启(大间隔判定)慢启动应用防误杀

探针示例

探针示例
containers:
  - name: web
    image: registry.example.com/team/web:1.2.3
    readinessProbe:
      httpGet: { path: /healthz, port: 8080 }
      periodSeconds: 5
      failureThreshold: 3
    livenessProbe:
      httpGet: { path: /livez, port: 8080 }
      periodSeconds: 10
      failureThreshold: 3
    startupProbe:
      httpGet: { path: /healthz, port: 8080 }
      periodSeconds: 5
      failureThreshold: 60
liveness 探针指向『会因外部依赖失败』的接口是经典错误:数据库抖动会引发全量重启风暴。liveness 只探进程自身活性。

易错点

  • liveness 探依赖(DB/缓存):外部抖动触发全副本重启,雪崩
  • readiness 探大计算逻辑:探测本身拖慢服务,延迟飙升

数据来源与参考

  • Kubernetes Docs:Liveness, Readiness, and Startup Probes

相关工具

​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌