CFN Cloud
Cloud Future New Life
en zh
2025-10-15 · 0 次浏览

探针(Probe)

让 Kubernetes 知道应用何时可用或需要重启。

探针决定 Pod 是否接流量,以及进程是否需要重启。

三类探针

  • readiness:是否可接流量
  • liveness:是否需要重启
  • startup:启动期保护

示例

readinessProbe:
  httpGet:
    path: /readyz
    port: 8080
  periodSeconds: 5
livenessProbe:
  httpGet:
    path: /livez
    port: 8080
  periodSeconds: 10

常见坑

  • 用 liveness 当“流量开关”
  • timeout 太小导致误判

实操要点

  • 先做快速盘点:kubectl get nodeskubectl get pods -Akubectl get events -A
  • 对比“期望状态”和“实际状态”,kubectl describe 往往能解释漂移或失败原因。
  • 名称、Label、Selector 要一致,避免 Service 或控制器找不到 Pod。

快速检查清单

  • 资源定义与业务意图一致。
  • Namespace、权限、镜像与环境匹配。
  • 上线前具备健康探针与可观测日志。

参考链接