# http: HTTP 探测失败，状态码：503

- **ID:** `kubernetes/kubelet-http-healthz-fail`
- **领域:** kubernetes
- **类别:** runtime_error
- **错误码:** `K8S-HTTP-503`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

应用程序的 HTTP 健康检查端点返回 503 状态，通常是因为应用未准备好提供服务或过载。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| kubernetes 1.22 | active | — | — |
| kubernetes 1.23 | active | — | — |
| kubernetes 1.27 | active | — | — |
| kubernetes 1.28 | active | — | — |

## 解决方案

1. ```
   检查应用程序日志中的启动错误或依赖项故障。例如，运行 `kubectl logs <pod-name> -c <container>` 并查找堆栈跟踪。
   ```
2. ```
   确保健康检查端点仅在所有依赖项（数据库、缓存）就绪时返回 200。如果应用程序需要时间初始化，请使用具有较长初始延迟的启动探测。
   ```

## 无效尝试

- **Increase the liveness probe threshold without fixing the app.** — This only masks the problem; the app remains unhealthy and may crash later. (70% 失败率)
- **Remove the readiness probe entirely.** — Removing the readiness probe can cause traffic to be routed to unhealthy pods, leading to user-facing errors. (85% 失败率)
