Loading...
Loading...
Compare original and translation side by side
| Aspect | Details |
|---|---|
| Input | Context Store from ln-770 |
| Output | Health check endpoints and Kubernetes probe configuration |
| Stacks | .NET (AspNetCore.Diagnostics.HealthChecks), Python (FastAPI routes) |
| 方面 | 详情 |
|---|---|
| 输入 | 来自ln-770的上下文存储 |
| 输出 | 健康检查端点和Kubernetes探针配置 |
| 技术栈 | .NET (AspNetCore.Diagnostics.HealthChecks), Python (FastAPI路由) |
STACKPROJECT_ROOTAddHealthChecksMapHealthChecks/health{ "status": "skipped" }| Dependency | .NET Detection | Python Detection |
|---|---|---|
| PostgreSQL | | |
| MySQL | | |
| Redis | | |
| RabbitMQ | | |
| MongoDB | | |
STACKPROJECT_ROOTAddHealthChecksMapHealthChecks/health{ "status": "skipped" }| 依赖项 | .NET 检测方式 | Python 检测方式 |
|---|---|---|
| PostgreSQL | csproj 中存在 | requirements 中存在 |
| MySQL | csproj 中存在 | requirements 中存在 |
| Redis | csproj 中存在 | requirements 中存在 |
| RabbitMQ | csproj 中存在 | requirements 中存在 |
| MongoDB | csproj 中存在 | requirements 中存在 |
| Endpoint | Probe Type | Purpose | Checks |
|---|---|---|---|
| Liveness | Is app alive? | App responds (no dependency checks) |
| Readiness | Can app serve traffic? | All dependencies healthy |
| Startup (K8s 1.16+) | Is app initialized? | Initial warmup complete |
| 端点 | 探针类型 | 用途 | 检查内容 |
|---|---|---|---|
| 存活探针 | 应用是否存活? | 应用可响应(不检查依赖项) |
| 就绪探针 | 应用能否处理流量? | 所有依赖项状态正常 |
| 启动探针(K8s 1.16+) | 应用是否完成初始化? | 初始预热完成 |
| Probe | Failure Action | Kubernetes Behavior |
|---|---|---|
| Liveness | Container restart | kubelet restarts container |
| Readiness | Remove from service | Traffic stopped, no restart |
| Startup | Delay other probes | Liveness/Readiness paused |
| 探针 | 失败操作 | Kubernetes 行为 |
|---|---|---|
| 存活探针 | 重启容器 | kubelet 重启容器 |
| 就绪探针 | 从服务中移除 | 停止流量转发,不重启容器 |
| 启动探针 | 延迟其他探针 | 存活/就绪探针暂停执行 |
MCP ref: "ASP.NET Core health checks Kubernetes probes"
Context7: /dotnet/aspnetcoreMCP ref: "FastAPI health check endpoint Kubernetes"
Context7: /tiangolo/fastapiMCP 参考: "ASP.NET Core health checks Kubernetes probes"
Context7: /dotnet/aspnetcoreMCP 参考: "FastAPI health check endpoint Kubernetes"
Context7: /tiangolo/fastapi| Parameter | Liveness | Readiness | Startup |
|---|---|---|---|
| 10 | 5 | 0 |
| 10 | 5 | 5 |
| 5 | 3 | 3 |
| 3 | 3 | 30 |
| 1 | 1 | 1 |
Max startup time = initialDelaySeconds + (periodSeconds × failureThreshold)
Default: 0 + (5 × 30) = 150 seconds| 参数 | 存活探针 | 就绪探针 | 启动探针 |
|---|---|---|---|
| 10 | 5 | 0 |
| 10 | 5 | 5 |
| 5 | 3 | 3 |
| 3 | 3 | 30 |
| 1 | 1 | 1 |
最大启动时间 = initialDelaySeconds + (periodSeconds × failureThreshold)
默认值: 0 + (5 × 30) = 150 秒| File | Purpose |
|---|---|
| Health check registration |
| Custom startup check |
AspNetCore.HealthChecks.NpgSqlAspNetCore.HealthChecks.RedisAspNetCore.HealthChecks.MySqlbuilder.Services.AddHealthCheckServices(builder.Configuration);
// ...
app.MapHealthCheckEndpoints();| 文件 | 用途 |
|---|---|
| 健康检查注册逻辑 |
| 自定义启动检查逻辑 |
AspNetCore.HealthChecks.NpgSqlAspNetCore.HealthChecks.RedisAspNetCore.HealthChecks.MySqlbuilder.Services.AddHealthCheckServices(builder.Configuration);
// ...
app.MapHealthCheckEndpoints();| File | Purpose |
|---|---|
| Health check router |
| Dependency health checks |
from routes.health import health_router
app.include_router(health_router)| 文件 | 用途 |
|---|---|
| 健康检查路由 |
| 依赖项健康检查服务 |
from routes.health import health_router
app.include_router(health_router)livenessProbe:
httpGet:
path: /health/live
port: 5000
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /health/ready
port: 5000
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
startupProbe:
httpGet:
path: /health/startup
port: 5000
periodSeconds: 5
failureThreshold: 30livenessProbe:
httpGet:
path: /health/live
port: 5000
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /health/ready
port: 5000
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
startupProbe:
httpGet:
path: /health/startup
port: 5000
periodSeconds: 5
failureThreshold: 30dotnet build --no-restorepython -m py_compile routes/health.pycurl http://localhost:5000/health/live
curl http://localhost:5000/health/ready
curl http://localhost:5000/health/startup{
"status": "Healthy",
"checks": {
"database": { "status": "Healthy", "duration": "00:00:00.0234" },
"redis": { "status": "Healthy", "duration": "00:00:00.0012" }
},
"totalDuration": "00:00:00.0250"
}/health/ready/health/livedotnet build --no-restorepython -m py_compile routes/health.pycurl http://localhost:5000/health/live
curl http://localhost:5000/health/ready
curl http://localhost:5000/health/startup{
"status": "Healthy",
"checks": {
"database": { "status": "Healthy", "duration": "00:00:00.0234" },
"redis": { "status": "Healthy", "duration": "00:00:00.0012" }
},
"totalDuration": "00:00:00.0250"
}/health/ready/health/live{
"status": "success",
"files_created": [
"Extensions/HealthCheckExtensions.cs",
"HealthChecks/StartupHealthCheck.cs"
],
"packages_added": [
"AspNetCore.HealthChecks.NpgSql"
],
"registration_code": "builder.Services.AddHealthCheckServices(configuration);",
"message": "Configured health checks with liveness, readiness, and startup probes"
}{
"status": "success",
"files_created": [
"Extensions/HealthCheckExtensions.cs",
"HealthChecks/StartupHealthCheck.cs"
],
"packages_added": [
"AspNetCore.HealthChecks.NpgSql"
],
"registration_code": "builder.Services.AddHealthCheckServices(configuration);",
"message": "Configured health checks with liveness, readiness, and startup probes"
}